/* 1. ИМПОРТ ШРИФТА И ПЕРЕМЕННЫЕ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --bg-dark: #020617;
  --accent: #22c55e;
  --accent-glow: rgba(34, 197, 94, 0.3);
  --blue: #3b82f6;
  --card-bg: rgba(255, 255, 255, 0.04);
  --card-border: rgba(255, 255, 255, 0.08);
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --muted: #94a3b8;
  --radius: 20px;
  --ok: #4ade80;
  --err: #f87171;
}

/* 2. БАЗОВЫЕ НАСТРОЙКИ */
* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', -apple-system, sans-serif;
  background-color: var(--bg-dark);
  /* Глубокий радиальный градиент на фоне */
  background-image: 
    radial-gradient(at 0% 0%, rgba(34, 197, 94, 0.12) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(30, 41, 59, 0.4) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-main);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

.wrap, .container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 40px 20px;
}

/* 3. ЛОГОТИП С ЗЕЛЕНОЙ РАМКОЙ */
.logo {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: #022c22;
  border: 2px solid var(--accent); /* Зеленая рамка */
  box-shadow: 0 0 15px var(--accent-glow); /* Свечение */
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: var(--accent);
  font-size: 20px;
  transition: transform 0.3s ease;
}

.logo:hover {
  transform: rotate(-5deg) scale(1.05);
}

/* 4. ШАПКА И НАВИГАЦИЯ */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 40px;
}

.brand { display: flex; align-items: center; gap: 16px; }

nav { display: flex; gap: 10px; }

.nav-link, .back-link {
  padding: 10px 20px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-muted);
  text-decoration: none;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  transition: all 0.2s ease;
}

.nav-link:hover, .back-link:hover {
  color: #fff;
  border-color: var(--accent);
  background: rgba(34, 197, 94, 0.05);
}

.nav-link-accent {
  background: rgba(34, 197, 94, 0.1) !important;
  color: var(--accent) !important;
  border-color: rgba(34, 197, 94, 0.3) !important;
}

/* 5. КАРТОЧКИ И ТИПОГРАФИКА */
.card, .note {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 30px;
  margin-bottom: 24px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

h1 {
  font-size: 2.4rem;
  font-weight: 800;
  margin: 0 0 10px;
  letter-spacing: -0.03em;
}

h2 {
  font-size: 1.5rem;
  color: var(--accent);
  margin-top: 40px;
}

/* 6. ПОИСК (Для notes.html) */
.search-input {
  width: 100%;
  padding: 16px 20px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  color: #fff;
  font-size: 16px;
  outline: none;
  transition: 0.3s;
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.1);
}

/* 7. СЕТКА И КАСКАДНАЯ АНИМАЦИЯ */
.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.note-item-wrapper {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 20px;
  transition: all 0.3s ease;
  opacity: 0; /* Для анимации */
  animation: fadeInUp 0.5s ease forwards;
}

/* Настройка очереди появления (каскад) */
.note-item-wrapper:nth-child(1) { animation-delay: 0.1s; }
.note-item-wrapper:nth-child(2) { animation-delay: 0.15s; }
.note-item-wrapper:nth-child(3) { animation-delay: 0.2s; }
.note-item-wrapper:nth-child(4) { animation-delay: 0.25s; }
.note-item-wrapper:nth-child(n+5) { animation-delay: 0.3s; }

.note-item-wrapper:hover {
  transform: translateY(-5px);
  border-color: var(--accent);
  background: rgba(34, 197, 94, 0.08);
}

.note-link {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: var(--text-main);
  font-weight: 600;
}

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

/* 8. АДАПТИВНОСТЬ */
@media (max-width: 768px) {
  header { flex-direction: column; gap: 25px; text-align: center; }
  .brand { flex-direction: column; }
  nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
    gap: 8px;
  }
  .nav-link { text-align: center; }
  h1 { font-size: 1.8rem; }
}

footer {
  text-align: center;
  padding: 60px 0;
  color: var(--text-muted);
  font-size: 14px;
}

/* --- LogicUp: общая навигация и оболочка страниц --- */
.app-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 28px;
}

.app-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.app-nav-link {
  padding: 9px 14px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  border: 1px solid transparent;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.app-nav-link:hover {
  color: #fff;
  background: var(--card-bg);
  border-color: var(--card-border);
}

.app-nav-link.is-active {
  color: var(--accent);
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.08);
}

.app-nav-link.nav-ai {
  color: #93c5fd;
  border-color: rgba(59, 130, 246, 0.25);
}

.app-nav-link.nav-ai:hover,
.app-nav-link.nav-ai.is-active {
  color: #bfdbfe;
  border-color: rgba(59, 130, 246, 0.5);
  background: rgba(59, 130, 246, 0.1);
}

/* Онбординг / демо */
.onboard-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  align-items: center;
  padding: 14px 18px;
  margin-bottom: 20px;
  border-radius: 14px;
  border: 1px solid rgba(34, 197, 94, 0.25);
  background: rgba(34, 197, 94, 0.06);
  font-size: 14px;
  line-height: 1.5;
}

.onboard-strip strong { color: var(--accent); }

.onboard-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--text-muted);
  font-size: 13px;
}

.onboard-steps li::before {
  content: "→ ";
  color: var(--accent);
  font-weight: 700;
}

.btn-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 12px;
  border: none;
  background: var(--accent);
  color: #022c22 !important;
  font-weight: 800;
  font-size: 15px;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn-cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px var(--accent-glow);
}

.btn-cta-secondary {
  background: transparent;
  color: var(--text-main) !important;
  border: 1px solid var(--card-border);
  font-weight: 700;
}

.btn-cta-secondary:hover {
  border-color: var(--accent);
  box-shadow: none;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.path-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.path-card {
  display: block;
  padding: 18px 16px;
  border-radius: 14px;
  text-decoration: none;
  color: var(--text-main);
  border: 1px solid var(--card-border);
  background: rgba(15, 23, 42, 0.4);
  transition: border-color 0.2s, transform 0.2s;
}

.path-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.path-card h3 {
  margin: 0 0 6px;
  font-size: 1rem;
  color: #fff;
}

.path-card p {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.45;
}

/* Прогресс */
.progress-pill {
  font-size: 12px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.12);
  color: var(--accent);
  border: 1px solid rgba(34, 197, 94, 0.25);
  white-space: nowrap;
}

.progress-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin: 16px 0 24px;
}

.stat-box {
  padding: 16px;
  border-radius: 14px;
  border: 1px solid var(--card-border);
  background: rgba(15, 23, 42, 0.45);
  text-align: center;
}

.stat-box .val {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.2;
}

.stat-box .lbl {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.improvement-banner {
  padding: 12px 16px;
  border-radius: 12px;
  margin-top: 12px;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid rgba(34, 197, 94, 0.3);
  background: rgba(34, 197, 94, 0.08);
  color: var(--ok);
}

.improvement-banner.warn {
  border-color: rgba(251, 191, 36, 0.35);
  background: rgba(251, 191, 36, 0.08);
  color: #fcd34d;
}

/* Квиз: мгновенная обратная связь */
.quiz-item.feedback-ok { border-color: rgba(74, 222, 128, 0.45); }
.quiz-item.feedback-err { border-color: rgba(248, 113, 113, 0.45); }
.quiz-instant {
  font-size: 13px;
  font-weight: 600;
  margin-top: 8px;
  min-height: 1.2em;
}
.quiz-instant.ok { color: var(--ok); }
.quiz-instant.err { color: var(--err); }

/* ИИ: пошаговый разбор */
.ai-explanation {
  margin-top: 10px;
}

.ai-step {
  padding: 12px 14px;
  margin-bottom: 10px;
  border-radius: 12px;
  border: 1px solid var(--card-border);
  background: rgba(15, 23, 42, 0.5);
}

.ai-step:last-child { margin-bottom: 0; }

.ai-step-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.ai-step-num {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: rgba(34, 197, 94, 0.2);
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ai-step-title {
  font-weight: 700;
  font-size: 14px;
  color: #e2e8f0;
}

.ai-step-body {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-muted);
  margin: 0;
  white-space: pre-wrap;
}

.ai-step-body strong { color: #e2e8f0; }

.ai-fallback-text {
  font-size: 14px;
  line-height: 1.65;
  color: #e2e8f0;
  white-space: pre-wrap;
}

/* Цель на день */
.goal-bar-wrap { margin: 16px 0 0; }
.goal-bar-head {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.goal-bar-head strong { color: var(--accent); }
.goal-bar-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.goal-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #4ade80);
  transition: width 0.35s ease;
}

/* Продолжить */
.continue-card {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  margin-bottom: 20px;
  border-radius: 14px;
  border: 1px solid rgba(59, 130, 246, 0.35);
  background: rgba(59, 130, 246, 0.08);
}
.continue-card p { margin: 4px 0 0; font-size: 13px; color: var(--text-muted); }

/* Следующее задание */
.task-actions-row { margin-top: 12px; }
.btn-next-task {
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: rgba(34, 197, 94, 0.12);
  color: var(--accent);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.btn-next-task:hover { border-color: var(--accent); }

/* Онбординг */
.onboard-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(2, 6, 23, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.onboard-modal { max-width: 420px; width: 100%; margin: 0; }
.onboard-step-num {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.onboard-body { color: var(--text-muted); line-height: 1.65; margin-bottom: 20px; }
.onboard-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

/* Рекомендации / слабые темы */
.rec-list { list-style: none; padding: 0; margin: 12px 0 0; }
.rec-list li { margin-bottom: 8px; }
.rec-link {
  display: block;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--card-border);
  text-decoration: none;
  color: var(--text-main);
  transition: border-color 0.2s;
}
.rec-link:hover { border-color: var(--accent); }
.rec-link strong { display: block; font-size: 14px; margin-bottom: 4px; }
.rec-link span { font-size: 12px; color: var(--text-muted); }
.rec-link.rec-continue { border-color: rgba(59, 130, 246, 0.4); background: rgba(59, 130, 246, 0.06); }

.return-banner {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  margin-bottom: 16px;
  border-radius: 12px;
  border: 1px solid rgba(251, 191, 36, 0.35);
  background: rgba(251, 191, 36, 0.08);
  font-size: 14px;
}

.streak-hero {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  padding: 12px 0 0;
}
.streak-hero .streak-num {
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent);
}

.feedback-preview {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--card-border);
  color: var(--text-muted);
}
.feedback-preview.is-wrong { border-color: rgba(248, 113, 113, 0.35); }
.btn-expand-ai {
  margin-top: 8px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid rgba(34, 197, 94, 0.35);
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font-family: inherit;
}
/* --- Исправления только для мобильных устройств (экраны меньше 768px) --- */
@media (max-width: 768px) {
    /* Исправляем блоки кода в конспектах */
    pre, code {
        white-space: pre-wrap !important; /* Принудительный перенос строк */
        word-wrap: break-word !important;  /* Разрыв слишком длинных слов */
        font-size: 14px;                 /* Чуть уменьшаем шрифт кода для мобилок */
        overflow-x: hidden;              /* Убираем лишнюю прокрутку */
    }

    /* Исправляем контейнеры, чтобы не было горизонтального скролла */
    .wrap, .container, .card, .note {
        max-width: 100vw !important;
        box-sizing: border-box !important;
        overflow-x: hidden !important; 
        padding-left: 15px !important;   /* Небольшие отступы по бокам */
        padding-right: 15px !important;
    }

    /* Таблицы (например в 7 или 14 задании) */
    table {
        display: block;
        width: 100%;
        overflow-x: auto; /* Разрешаем листать только таблицу, а не весь сайт */
        -webkit-overflow-scrolling: touch;
    }

    /* Изображения внутри конспектов */
    img {
        max-width: 100%;
        height: auto;
    }

    /* Сетка в списке конспектов */
    .notes-grid {
        grid-template-columns: 1fr !important; /* На телефоне карточки в один ряд */
    }
}
