/* Стили компонентов для математического тренажёра */

/* ===== Улучшение рендеринга шрифтов на Windows ===== */
* {
  text-rendering: optimizeLegibility;
}

/* Жирные шрифты должны быть четкими */
b, strong,
.stat-value,
.modal-stat-value,
.result-value,
.time-value {
  font-weight: 700;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Input и select элементы */
input, select, textarea {
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== Глобальная шапка ===== */
.global-header {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  background: white;
  border-bottom: 1px solid #e5e7eb;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
  z-index: 1000;
  padding: 6px 0;
}

.global-header-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

/* Логотип */
.header-logo {
  flex-shrink: 0;
}

.logo-image {
  height: 60px;
  width: auto;
  display: block;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.logo-image.mobile {
  display: none;
}

.logo-image:hover {
  transform: scale(1.05);
}

/* Статистика */
.header-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

/* Индикатор online/offline статуса */
.connection-status {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
  border-radius: 12px;
  transition: all 0.3s ease;
  cursor: default;
  user-select: none;
}

.connection-status.online {
  background: linear-gradient(135deg, #d1fae5 0%, #10b981 100%);
}

.connection-status.offline {
  background: linear-gradient(135deg, #fee2e2 0%, #ef4444 100%);
}

.connection-status.syncing {
  background: linear-gradient(135deg, #fef3c7 0%, #fbbf24 100%);
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9ca3af;
  transition: all 0.3s ease;
  position: relative;
}

.connection-status.online .status-indicator {
  background: #10b981;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}

.connection-status.offline .status-indicator {
  background: #ef4444;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
}

.connection-status.syncing .status-indicator {
  background: #fbbf24;
  box-shadow: 0 0 8px rgba(251, 191, 36, 0.6);
  animation: pulse-sync 1.5s ease-in-out infinite;
}

@keyframes pulse-sync {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.2);
    opacity: 0.7;
  }
}

.status-text {
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.connection-status.online .status-text {
  color: #047857;
}

.connection-status.offline .status-text {
  color: #dc2626;
}

.connection-status.syncing .status-text {
  color: #d97706;
}

.header-stats .stat-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
  border-radius: 12px;
  transition: all 0.3s ease;
  cursor: pointer;
  position: relative;
}

.header-stats .stat-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

/* Тултип для статистики */
.stat-tooltip {
  position: absolute;
  top: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%) scale(0.95);
  background: white;
  color: #1f2937;
  padding: 16px 20px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  white-space: normal;
  min-width: 280px;
  max-width: 320px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  pointer-events: none;
  opacity: 0;
  transition: all 0.2s ease;
  z-index: 1001;
  border: 2px solid #f3f4f6;
  word-break: break-word;
}

.stat-tooltip::before {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 8px solid transparent;
  border-bottom-color: white;
  filter: drop-shadow(0 -2px 2px rgba(0, 0, 0, 0.1));
}

.header-stats .stat-item.show-tooltip .stat-tooltip {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

.stat-tooltip-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 8px;
  color: #1f2937;
  word-break: break-word;
}

.stat-tooltip-icon {
  font-size: 22px;
}

.stat-tooltip-text {
  color: #6b7280;
  font-size: 13px;
  line-height: 1.6;
}

/* Календарь для серии побед */
.streak-calendar {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #e5e7eb;
}

.streak-calendar-label {
  font-size: 11px;
  font-weight: 600;
  color: #9ca3af;
  margin-right: 6px;
}

.streak-days {
  display: flex;
  gap: 3px;
}

.streak-day {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  background: #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 600;
  color: #9ca3af;
  transition: all 0.2s ease;
}

.streak-day.active {
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
  color: white;
  box-shadow: 0 2px 4px rgba(251, 191, 36, 0.3);
}

.header-stats .streak-stat {
  background: linear-gradient(135deg, #fef3c7 0%, #fbbf24 100%);
}

.header-stats .sapphire-stat {
  background: linear-gradient(135deg, #dbeafe 0%, #60a5fa 100%);
}

.header-stats .points-stat {
  background: linear-gradient(135deg, #e0e7ff 0%, #818cf8 100%);
}

.header-stats .stat-icon {
  font-size: 20px;
  line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
}

.header-stats .stat-value {
  font-size: 14px;
  font-weight: 700;
  color: #1f2937;
  min-width: 16px;
  text-align: center;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

/* Аватар */
.header-avatar {
  flex-shrink: 0;
}

.avatar-button {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 2px solid #667eea;
  background: white;
  padding: 2px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(102, 126, 234, 0.3);
}

.avatar-button:hover {
  transform: scale(1.1);
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.5);
}

.avatar-image {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

/* Модальное окно рейтинга */
.rating-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
}

.rating-modal.active {
  display: flex;
}

.rating-modal-content {
  background: white;
  border-radius: 24px;
  padding: 32px;
  max-width: 500px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.rating-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.rating-modal-title {
  font-size: 24px;
  font-weight: 700;
  color: #1f2937;
}

.rating-modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: #f3f4f6;
  font-size: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rating-modal-close:hover {
  background: #e5e7eb;
  transform: rotate(90deg);
}

.rating-modal-body {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.modal-rating-badge {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 16px;
  color: white;
  box-shadow: 0 4px 16px rgba(102, 126, 234, 0.4);
}

.modal-rating-icon {
  font-size: 48px;
}

.modal-rating-info {
  flex: 1;
}

.modal-rating-level {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 4px;
}

.modal-rating-score {
  font-size: 16px;
  opacity: 0.9;
}

.modal-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.modal-stat-card {
  padding: 16px;
  background: #f9fafb;
  border-radius: 12px;
  text-align: center;
}

.modal-stat-label {
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 4px;
}

.modal-stat-value {
  font-size: 24px;
  font-weight: 700;
  color: #1f2937;
}

/* Адаптивность шапки */
@media (max-width: 768px) {
  .global-header-container {
    padding: 0 16px;
  }

  .logo-image {
    display: none;
  }

  .logo-image.mobile {
    display: block;
    height: 35px;
  }

  .header-stats {
    gap: 8px;
  }

  .header-stats .stat-item {
    padding: 6px 12px;
  }

  .header-stats .stat-icon {
    font-size: 20px;
  }

  .header-stats .stat-value {
    font-size: 16px;
  }

  .connection-status {
    padding: 6px 10px;
  }

  .status-text {
    font-size: 11px;
  }

  .avatar-button {
    width: 40px;
    height: 40px;
  }
}

@media (max-width: 480px) {
  .header-stats {
    gap: 6px;
  }

  .header-stats .stat-item {
    padding: 4px 8px;
    gap: 4px;
  }

  .header-stats .stat-icon {
    font-size: 18px;
  }

  .header-stats .stat-value {
    font-size: 14px;
  }

  .connection-status {
    padding: 4px 8px;
    gap: 4px;
  }

  .status-indicator {
    width: 6px;
    height: 6px;
  }

  .status-text {
    font-size: 10px;
  }

  /* Компактный тултип на мобильных */
  .stat-tooltip {
    min-width: 200px;
    max-width: 260px;
    padding: 12px 16px;
    font-size: 12px;
    left: auto;
    right: 0;
    transform: translateX(0) scale(0.95);
  }

  .header-stats .stat-item.show-tooltip .stat-tooltip {
    transform: translateX(0) scale(1);
  }

  .stat-tooltip-title {
    font-size: 14px;
    flex-wrap: wrap;
  }

  .stat-tooltip-text {
    font-size: 11px;
  }
}

/* Главный экран - выбор уровня */
.header {
  text-align: center;
  margin-bottom: 48px;
  position: relative;
}

/* Глобальный рейтинг */
.global-rating {
  position: absolute;
  top: 0;
  right: 0;
}

.rating-badge {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 12px 20px;
  border-radius: 12px;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
  color: white;
  animation: fadeIn 0.5s ease-out;
}

.rating-icon {
  font-size: 32px;
  animation: pulse 2s ease-in-out infinite;
}

.rating-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.rating-title {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.2;
}

.rating-score {
  font-size: 14px;
  opacity: 0.9;
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

.grade-selection {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 40px;
  flex-wrap: wrap;
}

.grade-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 120px;
  height: 120px;
  background-color: var(--surface);
  border: 2px solid var(--border);
  border-radius: 16px;
  transition: all 0.3s ease;
}

.grade-btn:hover {
  background-color: var(--primary-blue);
  border-color: var(--primary-blue);
  color: white;
  transform: translateY(-4px);
  box-shadow: 0 8px 25px rgba(49, 162, 255, 0.3);
}

.grade-number {
  font-size: 36px;
  font-weight: 700;
  line-height: 1;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

.grade-label {
  font-size: 14px;
  margin-top: 4px;
}

.actions {
  text-align: center;
}

.settings-btn {
  background-color: var(--surface);
  color: var(--text-secondary);
  padding: 12px 20px;
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.settings-btn:hover {
  background-color: #EDF2F7;
  color: var(--text-primary);
}

/* Навигация */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
  font-size: 14px;
}

.current-grade {
  color: var(--text-secondary);
}

/* Карточки упражнений */
.exercise-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  max-width: 800px;
  margin: 0 auto;
}

.exercise-card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.exercise-card:hover {
  background-color: white;
  border-color: var(--primary-blue);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.exercise-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.exercise-icon {
  font-size: 32px;
}

.exercise-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.badge-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 16px;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.badge-circle.complete {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.badge-number {
  font-size: 16px;
}

.badge-label {
  font-size: 11px;
  color: #667eea;
  font-weight: 600;
}

.badge-circle.complete + .badge-label {
  color: #10b981;
}

.exercise-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.exercise-description {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.exercise-progress {
  margin-top: 16px;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.progress-text {
  font-weight: 600;
}

.progress-score {
  color: #667eea;
  font-weight: 700;
}

.progress-bar-container {
  width: 100%;
  height: 8px;
  background-color: #e0e0e0;
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
  border-radius: 4px;
  transition: width 0.5s ease;
}

.progress-bar-fill.complete {
  background: linear-gradient(90deg, #10b981 0%, #059669 100%);
}

/* Прогресс-бар для текущего примера (вверху) */
.question-progress-bar {
  width: 100%;
  height: 8px;
  background-color: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 20px;
}

.question-progress-fill {
  height: 100%;
  background-color: var(--warning-orange);
  width: 100%;
  transition: width 1s linear;
}

.training-footer {
  grid-area: footer;
  margin-top: 8px;
  padding-top: 16px;
}

.overall-progress-bar {
  width: 100%;
  height: 12px;
  background-color: var(--border);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 20px;
}

.overall-progress-fill {
  height: 100%;
  background-color: var(--success-green);
  width: 100%;
  transition: width 0.3s ease;
}

.exercise-switcher {
  margin-top: 16px;
  padding: 16px;
  background: white;
  border-radius: 12px;
  border: 2px solid #f0f0f0;
}

.switcher-title {
  font-size: 14px;
  font-weight: 600;
  color: #666;
  margin-bottom: 12px;
  text-align: center;
}

.switcher-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.switcher-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: white;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;
}

.switcher-btn:hover {
  border-color: #31a2ff;
  background: rgba(49, 162, 255, 0.05);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(49, 162, 255, 0.2);
}

.switcher-btn.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-color: #667eea;
  color: white;
}

.switcher-btn-icon {
  font-size: 16px;
}

.training-layout {
  display: grid;
  gap: 24px;
  grid-template-columns: 1fr 280px;
  grid-template-areas:
    "breadcrumbs breadcrumbs"
    "exercise stats"
    "footer footer";
}

/* Хлебные крошки */
.training-breadcrumbs {
  grid-area: breadcrumbs;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 0;
  font-size: 14px;
  color: #666;
  margin-bottom: 0;
  flex-wrap: wrap;
}

.breadcrumb-item {
  color: #666;
}

.breadcrumb-link {
  text-decoration: none;
  color: #667eea;
  transition: all 0.2s ease;
  cursor: pointer;
}

.breadcrumb-link:hover {
  color: #764ba2;
  text-decoration: underline;
}

.breadcrumb-current {
  font-weight: 600;
  color: #333;
  word-break: break-word;
}

.breadcrumb-separator {
  color: #ccc;
  font-weight: 300;
}

/* Блок отображения примера */
.exercise-display {
  grid-area: exercise;
  text-align: center;
}

/* Боковая панель статистики */
.stats-sidebar {
  grid-area: stats;
}

.stats-card {
  background-color: white;
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.stats-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 20px;
  text-align: center;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--border);
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  margin-bottom: 8px;
  background-color: var(--surface);
  border-radius: 10px;
  transition: transform 0.2s ease;
}

.stat-item:hover {
  transform: translateX(3px);
}

.stat-icon {
  font-size: 25px;
  width: 40px;
  height: 35px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background-color: white;
}

.correct-icon {
  background-color: rgba(0, 208, 132, 0.15);
  color: var(--success-green);
  font-size: 24px;
  font-weight: 700;
}

.incorrect-icon {
  background-color: rgba(255, 107, 107, 0.15);
  color: var(--error-red);
  font-size: 24px;
  font-weight: 700;
}

.streak-icon {
  font-size: 26px;
}

.record-icon {
  font-size: 26px;
}

.stat-details {
  flex: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.stat-label {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
}

.stat-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.streak-value {
  color: var(--warning-orange);
  font-size: 22px;
}

.time-remaining {
  margin-top: 16px;
  padding: 16px;
  background: linear-gradient(135deg, #9daae6 0%, #8b7c9a 100%);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: white;
}

.time-remaining .time-icon {
  font-size: 24px;
}

.time-remaining .time-value {
  font-size: 24px;
  font-weight: 700;
  font-family: var(--font-mono);
}


/* Контейнер для горизонтального и вертикального отображения */
.math-display-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  margin-bottom: 20px;
}

.math-problem {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 48px;
  font-weight: 700;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.02em;
}

/* Компактный столбик сбоку */
.compact-vertical {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  padding: 8px 12px;
  background-color: var(--surface);
  border-radius: 8px;
  border: 1px solid #e5e7eb;
}

.cv-line {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 600;
}

.cv-operand {
  min-width: 24px;
  text-align: right;
  color: #333;
}

.cv-first-num {
  color: #31a2ff;
}

.cv-second-num {
  color: #ff7849;
}

.cv-operator {
  color: #666;
  font-size: 14px;
  width: 16px;
}

/* Цветные цифры в примерах */
.first-operand {
  color: #31a2ff; /* синий */
}

.second-operand {
  color: #ff7849; /* оранжевый */
}

.answer-input {
  font-family: var(--font-mono);
  font-size: 48px;
  font-weight: 700;
  width: 120px;
  text-align: center;
  border: none;
  border-radius: 8px;
  padding: 8px;
  background-color: var(--surface);
  caret-color: transparent; /* Убираем курсор */
  transition: all 0.2s ease;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.02em;
}

/* Убираем стрелки у input type="number" */
.answer-input::-webkit-outer-spin-button,
.answer-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.answer-input[type="number"] {
  -moz-appearance: textfield;
}

.answer-input:focus {
  background-color: white;
  outline: none;
  box-shadow: 0 0 0 3px rgba(49, 162, 255, 0.3);
}

.answer-input:hover {
  background-color: white;
}

/* Стили для анимации обратной связи */
.answer-input.correct {
  background-color: rgba(0, 208, 132, 0.2) !important;
  box-shadow: 0 0 0 3px rgba(0, 208, 132, 0.3) !important;
}

.answer-input.incorrect {
  background-color: rgba(255, 107, 107, 0.2) !important;
  box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.3) !important;
}

/* Кнопки сравнения */
.comparison-buttons {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-top: 24px;
  animation: fadeIn 0.3s ease-out;
}

.comparison-btn {
  font-family: var(--font-mono);
  font-size: 48px;
  font-weight: 700;
  width: 100px;
  height: 100px;
  border-radius: 16px;
  border: 3px solid #e5e7eb;
  background: linear-gradient(135deg, #ffffff 0%, #f9fafb 100%);
  color: #374151;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
}

.comparison-btn:hover {
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border-color: #3b82f6;
  color: #1e40af;
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(59, 130, 246, 0.2);
}

.comparison-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
}

.comparison-btn.selected {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  border-color: #2563eb;
  color: white;
  box-shadow: 0 6px 12px rgba(59, 130, 246, 0.4);
}

/* История примеров */
.exercise-history {
  margin: 20px auto 0;
  min-height: 350px;
  width: 350px;
}

.exercise-history h3 {
  font-size: 16px;
  margin-bottom: 12px;
  color: var(--text-secondary);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background-color: var(--surface);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 14px;
}

.history-item.correct {
  background-color: rgba(0, 208, 132, 0.1);
  color: var(--success-green);
}

.history-item.incorrect {
  background-color: rgba(255, 107, 107, 0.1);
  color: var(--error-red);
}

/* Статистика тренировки (старый блок, возможно не используется) */
.training-stats {
  display: flex;
  justify-content: space-around;
  margin-bottom: 32px;
  padding: 20px;
  background-color: var(--surface);
  border-radius: 12px;
}

.training-stats .stat {
  text-align: center;
}

.training-stats .stat-label {
  display: block;
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.training-stats .stat-value {
  display: block;
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

.action-buttons {
  margin-top: 16px;
  text-align: right;
}

.dont-know-btn {
  background-color: #ffb80000;
  color: #ffb800;
  /*padding: 12px 24px;*/
  font-weight: 600;
  margin-bottom: 12px;
}

.dont-know-btn:hover {
  background-color: #ffb80000;
  transform: translateY(-1px);
  color: #8d351f;
}

.keyboard-hints {
  margin-top: 8px;
}

.keyboard-hints small {
  color: var(--text-secondary);
  font-size: 12px;
}

/* Экран результатов */
.results-content {
  max-width: 500px;
  margin: 0 auto;
  text-align: center;
}

.results-summary {
  background-color: var(--surface);
  border-radius: 12px;
  padding: 32px;
  margin-bottom: 32px;
}

.result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.result-item:last-child {
  border-bottom: none;
}

.result-label {
  font-size: 16px;
  color: var(--text-secondary);
}

.result-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Экран настроек */
.settings-content {
  max-width: 750px;
  margin: 0 auto;
}

.settings-form {
  background-color: var(--surface);
  border-radius: 12px;
  padding: 32px;
}

.setting-group {
  margin-bottom: 32px;
  padding: 24px;
  background: white;
  border-radius: 12px;
  border: 2px solid #f0f0f0;
  transition: all 0.3s ease;
}

.setting-group:hover {
  border-color: #31a2ff;
  box-shadow: 0 4px 12px rgba(49, 162, 255, 0.1);
}

.student-name-group {
  background: linear-gradient(135deg, #667eea15 0%, #764ba215 100%);
  border-color: #667eea;
}

.setting-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.label-icon {
  font-size: 20px;
}

.setting-input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 16px;
  font-family: inherit;
  transition: all 0.3s ease;
  background: white;
}

.setting-input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.setting-hint {
  display: block;
  margin-top: 8px;
  color: #666;
  font-size: 13px;
}

.grade-options {
  display: flex;
  flex-direction: row;
  gap: 12px;
  justify-content: space-between;
}

.operation-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.radio-option,
.checkbox-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border: 2px solid #e0e0e0;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  background: white;
  position: relative;
}

.radio-option:hover,
.checkbox-option:hover {
  border-color: #31a2ff;
  background-color: rgba(49, 162, 255, 0.05);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(49, 162, 255, 0.15);
}

.radio-option input:checked + .option-content,
.checkbox-option input:checked + .option-badge {
  color: #667eea;
}

.radio-option input:checked,
.checkbox-option input:checked {
  accent-color: #667eea;
}

.radio-option input[type="radio"],
.checkbox-option input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

.option-content {
  display: flex;
  align-items: center;
  gap: 8px;
}

.option-number {
  font-size: 24px;
  font-weight: 700;
  color: #667eea;
}

.option-text {
  font-size: 14px;
  color: #666;
}

.option-badge {
  display: flex;
  align-items: center;
  gap: 10px;
}

.badge-icon {
  font-size: 22px;
}

.badge-text {
  font-size: 15px;
  font-weight: 500;
}

.setting-select {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  background-color: white;
  font-size: 16px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.3s ease;
}

.setting-select:hover {
  border-color: #31a2ff;
}

.setting-select:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.setting-actions {
  text-align: center;
  margin-top: 40px;
}

.setting-actions .primary-btn {
  padding: 16px 48px;
  font-size: 18px;
  font-weight: 600;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  color: white;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.setting-actions .primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

/* Модальное окно */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease-out;
}

.modal-overlay.active {
  display: flex;
}

.modal-dialog {
  background-color: white;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 450px;
  width: 90%;
  animation: slideUp 0.3s ease-out;
  overflow: hidden;
}

.modal-header {
  padding: 24px 24px 16px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
}

.modal-message {
  margin: 0;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-secondary);
  white-space: pre-line;
}

.modal-footer {
  padding: 16px 24px 24px;
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.modal-btn {
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
}

.modal-btn-primary {
  background-color: var(--primary-blue);
  color: white;
}

.modal-btn-primary:hover {
  background-color: #2B8FE5;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(49, 162, 255, 0.3);
}

.modal-btn-secondary {
  background-color: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.modal-btn-secondary:hover {
  background-color: #EDF2F7;
  color: var(--text-primary);
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Уведомление о серии правильных ответов */
.streak-celebration {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 24px 40px;
  border-radius: 16px;
  font-size: 24px;
  font-weight: 700;
  box-shadow: 0 20px 60px rgba(102, 126, 234, 0.4);
  z-index: 2000;
  opacity: 0;
  transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  pointer-events: none;
}

.streak-celebration.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* Всплывающий индикатор очков (+1/-2) */
.score-popup {
  position: fixed;
  font-size: 65px;
  font-weight: 700;
  pointer-events: none;
  z-index: 1000;
  white-space: nowrap;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  line-height: 1;
}

.score-popup.positive {
  color: var(--success-green);
  animation: floatUpFadePositive 1s ease-out forwards;
  text-shadow: 0 2px 8px rgba(76, 175, 80, 0.5);
}

.score-popup.negative {
  color: var(--error-red);
  animation: floatUpFadeNegative 1s ease-out forwards;
  text-shadow: 0 2px 8px rgba(244, 67, 54, 0.5);
}

/* Адаптивность для компонентов */
@media (max-width: 1024px) {
  .training-layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "breadcrumbs"
      "exercise"
      "stats"
      "footer";
    gap: 16px;
  }

  .question-progress-bar {
    margin-bottom: 16px;
  }

  .exercise-history {
    min-height: 150px;
    margin-top: 20px;
  }

  .action-buttons {
    margin-top: 12px;
  }

  /* Статистика в виде сетки */
  .stats-card {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 16px;
  }

  .stats-title {
    grid-column: 1 / -1;
    margin-bottom: 8px;
  }

  .time-remaining {
    grid-column: 1 / -1;
    margin-top: 8px;
  }

  .stat-item {
    margin-bottom: 0;
  }
}

@media (max-width: 1024px) {
  .math-display-container {
    flex-direction: column;
    gap: 12px;
  }

  .compact-vertical {
    padding: 6px 10px;
  }

  .cv-line {
    font-size: 14px;
  }

  .cv-operand {
    min-width: 20px;
  }

  .cv-operator {
    font-size: 12px;
    width: 14px;
  }
}

@media (max-width: 768px) {
  .training-layout {
    gap: 16px;
  }

  .training-breadcrumbs {
    font-size: 12px;
    gap: 6px;
    padding: 8px 0;
  }

  /* Компактный столбик на мобильных */
  .math-display-container {
    flex-direction: column;
    gap: 10px;
  }

  .compact-vertical {
    padding: 5px 8px;
  }

  .cv-line {
    font-size: 13px;
  }

  .cv-operand {
    min-width: 18px;
  }

  .cv-operator {
    font-size: 11px;
    width: 12px;
  }

  .breadcrumb-current {
    max-width: 100%;
    line-height: 1.4;
  }

  .global-rating {
    position: static;
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
  }

  .rating-badge {
    padding: 10px 16px;
    gap: 10px;
  }

  .rating-icon {
    font-size: 28px;
  }

  .rating-title {
    font-size: 16px;
  }

  .rating-score {
    font-size: 13px;
  }

  .grade-selection {
    gap: 16px;
  }

  .grade-btn {
    width: 100px;
    height: 100px;
  }

  .grade-number {
    font-size: 28px;
  }

  /* Компактная статистика на мобильных */
  .stats-card {
    padding: 12px;
    gap: 8px;
  }

  .stats-title {
    font-size: 15px;
    margin-bottom: 10px;
    padding-bottom: 8px;
  }

  .stat-item {
    padding: 6px 8px;
    gap: 8px;
  }

  .stat-icon {
    width: 28px;
    height: 28px;
    font-size: 16px;
  }

  .correct-icon,
  .incorrect-icon {
    font-size: 18px;
  }

  .stat-label {
    font-size: 11px;
  }

  .stat-value {
    font-size: 15px;
  }

  .time-remaining {
    padding: 10px;
  }

  .time-remaining .time-icon {
    font-size: 18px;
  }

  .time-remaining .time-value {
    font-size: 18px;
  }

  /* Крупные примеры на мобильных */
  .math-problem {
    font-size: 48px;
    gap: 8px;
    margin-bottom: 20px;
  }

  .answer-input {
    font-size: 48px;
    width: 140px;
  }

  .comparison-btn {
    font-size: 40px;
    width: 90px;
    height: 90px;
  }

  .training-stats {
    flex-direction: column;
    gap: 16px;
  }

  .result-actions {
    gap: 8px;
  }

  /* История примеров */
  .exercise-history {
    min-height: 150px;
  }

  .exercise-history h3 {
    font-size: 13px;
    margin-bottom: 8px;
  }

  .history-list {
    gap: 6px;
  }

  .history-item {
    padding: 6px 10px;
    font-size: 13px;
  }

  /* Переключатель упражнений на мобильных */
  .exercise-switcher {
    padding: 12px;
    margin-top: 12px;
  }

  .switcher-title {
    font-size: 12px;
    margin-bottom: 10px;
  }

  .switcher-buttons {
    gap: 8px;
  }

  .switcher-btn {
    padding: 8px 12px;
    font-size: 12px;
    gap: 4px;
  }

  .switcher-btn-icon {
    font-size: 14px;
  }
}

@media (max-width: 480px) {
  .training-layout {
    gap: 12px;
  }

  .grade-btn {
    width: 80px;
    height: 80px;
  }

  .grade-number {
    font-size: 24px;
  }

  /* Крупные примеры */
  .math-problem {
    font-size: 42px;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 16px;
  }

  .answer-input {
    font-size: 42px;
    width: 120px;
  }

  .comparison-buttons {
    gap: 10px;
    margin-top: 16px;
  }

  .comparison-btn {
    font-size: 36px;
    width: 80px;
    height: 80px;
  }

  /* Компактная статистика */
  .stats-card {
    padding: 10px;
    gap: 6px;
  }

  .stat-item {
    padding: 5px 6px;
  }

  .stat-icon {
    width: 24px;
    height: 24px;
    font-size: 14px;
  }

  .stat-label {
    font-size: 10px;
  }

  .stat-value {
    font-size: 14px;
  }

  .time-remaining {
    padding: 8px;
  }

  .time-remaining .time-value {
    font-size: 16px;
  }

  /* История */
  .exercise-history {
    min-height: 150px;
  }

  .exercise-history h3 {
    font-size: 12px;
    margin-bottom: 6px;
  }

  .history-item {
    padding: 5px 8px;
    font-size: 12px;
  }

  /* Переключатель упражнений */
  .exercise-switcher {
    padding: 10px;
    margin-top: 10px;
  }

  .switcher-title {
    font-size: 11px;
    margin-bottom: 8px;
  }

  .switcher-buttons {
    gap: 6px;
  }

  .switcher-btn {
    padding: 6px 10px;
    font-size: 11px;
    gap: 3px;
  }

  .switcher-btn-icon {
    font-size: 12px;
  }
}

/* Стили для сообщений о результате упражнения */
.exercise-result-message {
  margin: 20px 0;
  padding: 20px;
  border-radius: 12px;
  animation: slideInDown 0.5s ease-out;
}

.exercise-result-message.success {
  background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
  border: 2px solid #2f855a;
}

.exercise-result-message.failure {
  background: linear-gradient(135deg, #f56565 0%, #e53e3e 100%);
  border: 2px solid #c53030;
}

.result-success,
.result-failure {
  display: flex;
  align-items: center;
  gap: 16px;
  color: white;
}

.result-icon {
  font-size: 32px;
  flex-shrink: 0;
}

.result-text h3 {
  margin: 0 0 8px 0;
  font-size: 20px;
  font-weight: 700;
}

.result-text p {
  margin: 0;
  font-size: 16px;
  opacity: 0.9;
}

@keyframes slideInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== Стили для настраиваемого тренажёра ===== */

.custom-trainer-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 16px 24px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
  margin-top: 24px;
  width: 100%;
  max-width: 280px;
  margin-left: auto;
  margin-right: auto;
  display: flex;
}

.custom-trainer-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

.custom-trainer-btn:active {
  transform: translateY(0);
}

.custom-trainer-form {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px;
  max-width: 600px;
  margin: 0 auto;
}

.custom-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.section-title {
  font-size: 18px;
  font-weight: 700;
  color: #1f2937;
  margin: 0;
  padding-bottom: 12px;
  border-bottom: 2px solid #e5e7eb;
}

.operations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 12px;
}

.operation-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  background: white;
}

.operation-checkbox:hover {
  border-color: #667eea;
  background: #f3f4f6;
}

.operation-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: #667eea;
}

.operation-checkbox input[type="checkbox"]:checked + .checkbox-label {
  color: #667eea;
  font-weight: 600;
}

.checkbox-label {
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: #374151;
}

.operation-checkbox:has(input:checked) {
  border-color: #667eea;
  background: #eef2ff;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.custom-trainer-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  padding-top: 16px;
}

.custom-trainer-actions .primary-btn {
  min-width: 200px;
  padding: 14px 24px;
  font-size: 16px;
  font-weight: 600;
}
/* Кно
пки действий в шапке (история, выход) */
.header-action {
  flex-shrink: 0;
}

.history-button,
.logout-button {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid #e5e7eb;
  background: white;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.history-button:hover,
.logout-button:hover {
  transform: scale(1.1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  border-color: var(--primary-blue);
}

.history-icon,
.logout-icon {
  display: block;
  line-height: 1;
}

@media (max-width: 768px) {
  .history-button,
  .logout-button {
    width: 40px;
    height: 40px;
    font-size: 18px;
  }
}
