/* Учебка — мобильные правила личного демокабинета.
   Подключается ПОСЛЕ встроенных стилей my-uchebka-demo.html и переопределяет только
   мобильную раскладку. Базовые (десктопные) стили остаются во встроенном блоке,
   поэтому при недоступности этого файла кабинет остаётся работоспособным:
   видна боковая навигация, все четыре раздела и ссылки продолжают работать.
   Демонстрация: никаких оценок знаний, только просмотренные ситуации. */

/* ── Планшет: узкая боковая панель ───────────────────────────────────── */
@media (max-width: 920px) {
  .sidebar { width: 196px; padding: 24px 15px; }
  .sidebar .logo img { width: 142px; height: 54px; }
  main { margin-left: 196px; padding-top: 22px; }
  .grid { grid-template-columns: 1fr; }
  .panel { padding: 20px; }
}

/* ── Телефон: нижняя панель вместо боковой ───────────────────────────── */
@media (max-width: 690px) {
  .sidebar { display: none; }
  main {
    margin: 0;
    padding: 14px 13px calc(84px + env(safe-area-inset-bottom));
  }

  header { margin-bottom: 14px; gap: 8px; }
  .breadcrumb { font-size: 11px; letter-spacing: .1em; }
  .header-right { gap: 6px; width: 100%; }
  .header-right .pill,
  .header-right .ghost,
  .header-right button { font-size: 12px; padding: 9px 11px; }

  h1 { font-size: clamp(26px, 8vw, 32px); }
  h2 { font-size: 19px; }
  .intro { margin-bottom: 16px; font-size: 14px; }
  .banner { padding: 10px 12px; margin-bottom: 14px; }

  .grid { gap: 12px; }
  .panel { padding: 16px; border-radius: 16px; box-shadow: none; }
  .hero { min-height: 0; padding: 18px; gap: 16px; }
  .hero h2 { font-size: 21px; }
  .hero-footer { gap: 8px; }

  /* Счётчик просмотренных ситуаций: компактнее, но без «процентов знаний» */
  .stat-value { font-size: 30px; }
  .meter { margin: 13px 0 8px; }

  .chips { gap: 6px; }
  .chip { font-size: 12px; padding: 8px 10px; }

  .lesson { gap: 11px; padding-bottom: 13px; }
  .lesson-icon { width: 38px; height: 38px; flex-basis: 38px; font-size: 18px; border-radius: 10px; }
  .lesson-main small { font-size: 12px; }

  .topic-row { grid-template-columns: 1fr; gap: 4px; padding: 11px 0; }
  .topic-row .status { justify-self: start; }

  /* Раздел «Мой ИИ-наставник»: сначала выбор темы и манеры, затем диалог */
  #teacher .grid > .panel:first-child { display: flex; flex-direction: column; gap: 0; }
  #teacher .ai-head { order: 0; padding: 12px; }
  #teacher .ai-head .avatar { width: 44px; height: 44px; flex-basis: 44px; font-size: 22px; border-radius: 14px; }
  #teacher .dialog-controls { order: 1; margin-top: 13px; scroll-margin-bottom: 96px; }
  #teacher .mentor-topic-panel { order: 2; scroll-margin-bottom: 96px; padding: 14px; }
  #teacher .chat { order: 3; min-height: 120px; margin: 12px 0; padding: 12px; }
  #teacher .note { order: 4; margin-top: 4px; }
  .bubble { max-width: 94%; font-size: 14px; }

  /* Нижняя навигация по четырём разделам кабинета */
  .mobilebar {
    display: grid;
    position: fixed;
    inset: auto 0 0 0;
    grid-template-columns: repeat(4, 1fr);
    background: #fff;
    border-top: 1px solid #c9dbc9;
    padding: 6px 3px max(6px, env(safe-area-inset-bottom));
    z-index: 5;
  }
  .mobilebar button {
    border: 0;
    background: transparent;
    color: #4c6654;
    display: grid;
    justify-items: center;
    align-content: center;
    gap: 3px;
    min-height: 48px;
    padding: 5px 3px;
    font-size: 10px;
    font-weight: 700;
    line-height: 1.1;
  }
  .mobilebar button span { font-size: 21px; line-height: 1; }
  .mobilebar button.active { color: #1b5c38; }
  .mobilebar button.active span { color: #1b5c38; }
  .mobilebar button:focus-visible { outline: 3px solid #2f6a45; outline-offset: -3px; border-radius: 10px; }

  /* Вход по ФИО и телефону — без пароля, СМС и кодов */
  .login-gate { align-items: flex-start; padding: 14px 12px calc(20px + env(safe-area-inset-bottom)); }
  .login-box { border-radius: 18px; padding: 18px 16px 20px; box-shadow: 0 14px 34px #0005; }
  .login-box .logo img { width: 158px; }
  .login-kicker { margin: 16px 0 8px; }
  .login-box h1 { font-size: clamp(25px, 7.5vw, 33px); }
  .login-box label { margin: 18px 0 7px; }
  .login-box .disclaimer { margin-top: 15px; }
}

/* ── Очень узкие экраны (iPhone SE и подобные) ───────────────────────── */
@media (max-width: 360px) {
  main { padding-left: 10px; padding-right: 10px; }
  .panel { padding: 14px; }
  .mobilebar button { font-size: 9px; }
  .mobilebar button span { font-size: 19px; }
}

/* ── Крупные тач-зоны там, где нет точного указателя ─────────────────── */
@media (hover: none) and (pointer: coarse) {
  .dialog-controls button,
  .quickbtn,
  .styleset button,
  .ghost,
  #demoLogout,
  #demoDeleteProfile { min-height: 44px; }
  .lesson a { display: inline-block; padding: 8px 0; }
  body { -webkit-text-size-adjust: 100%; }
}

/* ── Производительность и доступность на телефоне ────────────────────── */
@media (max-width: 690px) {
  /* Скрытые разделы не участвуют в вычислении раскладки при переключении таб. */
  .section { contain: layout style; }
  html { scroll-behavior: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
