/* Общая оболочка: левый сайдбар (как на карте подготовки) + основной контент */

body.student-app .site-header {
  display: none !important;
}

body.student-app .plan-session__header.hidden {
  display: none !important;
}

body.student-app .site-app-frame__main {
  background: var(--pd-v2-bg, #f3f6f4);
  min-height: 100vh;
}

body.student-app .student-shell__topbar-wrap {
  padding: 20px 24px 0;
  max-width: none;
}

body.student-app .student-shell__stats-wrap {
  padding: 0 24px;
  margin-top: 2px;
  margin-bottom: 0;
}

body.student-app .student-shell__stats-wrap .th2-stats-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-bottom: 0;
  padding: 4px 0 2px;
  font-size: 0.88rem;
  color: #374151;
}

body.student-app .student-shell__stats-wrap .th2-stat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid #e5e7eb;
}

body.student-app .student-shell__stats-wrap .th2-stat--level {
  min-width: 140px;
}

body.student-app .student-shell__stats-wrap .th2-stat__bar {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: #e5e7eb;
  overflow: hidden;
  min-width: 60px;
}

body.student-app .student-shell__stats-wrap .th2-stat__bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #4ade80, #22c55e);
  border-radius: 999px;
}

body.student-app .theory-layout,
body.student-app .lk-layout {
  padding: 0 24px 48px;
  max-width: none;
  width: 100%;
}

body.student-app .plan-session__stepper,
body.student-app .plan-session__main,
body.student-app .plan-session__footer,
body.student-app .plan-session__alert {
  padding-left: 24px;
  padding-right: 24px;
}

body.student-app .prep-dash__history-page {
  padding: 0 24px 48px;
}

.site-app-frame {
  display: flex;
  align-items: stretch;
  min-height: 100vh;
  width: 100%;
}

.site-app-frame__main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* Глобальный сайдбар: фиксированная ширина, иначе flex растягивает его по контенту */
.site-global-sidebar.prep-dash__sidebar {
  flex: 0 0 var(--pd-sidebar, 240px);
  width: var(--pd-sidebar, 240px);
  max-width: var(--pd-sidebar, 240px);
  min-width: var(--pd-sidebar, 240px);
  overflow-x: hidden;
  overflow-y: auto;
  box-sizing: border-box;
}

@media (min-width: 901px) {
  .site-app-frame {
    flex-direction: row;
    align-items: flex-start;
  }

  body.prep-dash.use-app-shell .site-app-frame__main {
    flex: 1 1 0;
    min-width: 0;
    width: 0;
  }

  body.use-app-shell:not(.prep-dash) .site-app-frame__main {
    flex: 1 1 auto;
    min-width: 0;
    width: auto;
  }
}

.site-global-sidebar .prep-dash__nav a.is-disabled {
  opacity: 0.45;
  pointer-events: none;
  cursor: default;
}

@media (max-width: 900px) {
  .site-app-frame {
    flex-direction: column;
  }

  .site-global-sidebar.prep-dash__sidebar {
    flex: 0 0 auto;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: auto;
    position: sticky;
    top: 0;
    z-index: 40;
    min-height: 0;
    padding: 12px 14px;
    border-right: none;
    border-bottom: 1px solid #e2ebe6;
  }

  .site-app-frame__main {
    width: 100%;
  }

  .site-global-sidebar .prep-dash__brand-tag {
    display: none;
  }

  .site-global-sidebar .prep-dash__nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
  }

  .site-global-sidebar .prep-dash__nav a {
    padding: 8px 10px;
    font-size: 0.85rem;
    flex: 1 1 auto;
    justify-content: center;
    min-width: calc(50% - 6px);
  }

  .site-global-sidebar .prep-dash__nav-icon {
    width: 1.1em;
  }
}

/* Мобильная нижняя панель */
.site-bottom-nav {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  background: #fff;
  border-top: 1px solid #e2ebe6;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0));
  justify-content: space-around;
  gap: 2px;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.06);
}

body.has-site-bottom-nav {
  padding-bottom: calc(64px + env(safe-area-inset-bottom, 0));
}

.site-bottom-nav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 4px;
  text-decoration: none;
  color: #5a6b63;
  font-size: 0.72rem;
  border-radius: 8px;
  min-width: 0;
  min-height: 52px;
}

.site-bottom-nav__item.is-active {
  color: #1a5f4a;
  background: #eef7f1;
}

.site-bottom-nav__icon {
  font-size: 1.15rem;
  line-height: 1;
}

.site-bottom-nav__label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

@media (max-width: 640px) {
  .site-bottom-nav {
    display: flex;
  }

  body.has-site-bottom-nav .site-global-sidebar .site-app-shell__nav {
    display: none;
  }

  body.has-site-bottom-nav .site-global-sidebar {
    padding-bottom: 8px;
  }

  .site-app-shell-ege-wrap {
    display: none;
  }

  #siteAppShellExtras {
    display: none;
  }
}

.site-skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 1000;
  padding: 10px 14px;
  border-radius: 8px;
  background: #0f766e;
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  transform: translateY(-160%);
}

.site-skip-link:focus {
  transform: translateY(0);
}

/* Блок «Попробовать сдать ЕГЭ» — на всех страницах с app-shell */
.site-app-shell-ege-wrap {
  margin: 8px 0 12px;
}

.prep-dash__ege-cta,
.site-shell-ege-cta {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 14px;
  border-radius: 14px;
  text-decoration: none;
  color: #78350f;
  background: linear-gradient(160deg, #fffbeb 0%, #fef3c7 45%, #fde68a 100%);
  border: 2px solid #fbbf24;
  box-shadow: 0 3px 14px rgba(245, 158, 11, 0.22);
  transition: box-shadow 0.15s, transform 0.15s, border-color 0.15s;
}

.prep-dash__ege-cta:hover,
.site-shell-ege-cta:hover {
  border-color: #f59e0b;
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.3);
  transform: translateY(-1px);
  color: #713f12;
}

.prep-dash__ege-cta-main {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
}

.prep-dash__ege-cta-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  background: rgba(255, 255, 255, 0.65);
  border-radius: 10px;
  border: 1px solid rgba(251, 191, 36, 0.5);
}

.prep-dash__ege-cta-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1;
}

.prep-dash__ege-cta-text {
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.25;
  color: #92400e;
}

.prep-dash__ege-cta-sub {
  font-size: 0.72rem;
  color: #a16207;
  line-height: 1.25;
}

.prep-dash__ege-cta-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #422006;
  background: linear-gradient(180deg, #fde047 0%, #facc15 50%, #eab308 100%);
  border: 1px solid #ca8a04;
  box-shadow: 0 2px 0 #b45309, 0 4px 12px rgba(180, 83, 9, 0.25);
  transition: filter 0.15s, transform 0.1s;
}

.prep-dash__ege-cta:hover .prep-dash__ege-cta-btn {
  filter: brightness(1.05);
}

.prep-dash__ege-cta:active .prep-dash__ege-cta-btn {
  transform: translateY(1px);
  box-shadow: 0 1px 0 #b45309, 0 2px 6px rgba(180, 83, 9, 0.2);
}

/* Виджеты карты (только prep-dashboard) */
#siteAppShellExtras .prep-dash__widget {
  margin-top: 12px;
}

#siteAppShellExtras .prep-dash__sidebar-panels {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

#siteAppShellExtras .prep-dash__panel--sidebar {
  padding: 14px;
}

#siteAppShellExtras .prep-dash__panel--sidebar .prep-dash__panel-title {
  font-size: 0.92rem;
  margin-bottom: 10px;
}

#siteAppShellExtras .prep-dash__panel--sidebar .prep-dash__achievements li,
#siteAppShellExtras .prep-dash__panel--sidebar .prep-dash__stats-list li {
  padding: 7px 0;
  font-size: 0.82rem;
}

#siteAppShellExtras .prep-dash__achievements a {
  color: inherit;
  text-decoration: none;
}

#siteAppShellExtras .prep-dash__achievements a:hover {
  color: var(--pd-green, #1a5f4a);
}

/* Теория: дерево КЭС в общем левом меню */
body.theory-page {
  --pd-sidebar: 272px;
}
body.theory-page .site-global-sidebar.prep-dash__sidebar {
  flex: 0 0 var(--pd-sidebar, 272px);
  width: var(--pd-sidebar, 272px);
  max-width: var(--pd-sidebar, 272px);
  min-width: var(--pd-sidebar, 272px);
  height: 100vh;
  max-height: 100vh;
  position: sticky;
  top: 0;
  overflow-x: hidden;
  overflow-y: auto;
}
.theory-shell-kes {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #e2ebe6;
}
.theory-shell-kes__title {
  margin: 0 0 10px;
  font-weight: 700;
  color: #1a5f4a;
  font-size: 0.82rem;
  line-height: 1.3;
}
/* Одна прокрутка на всю левую колонку — без отдельного скролла у дерева КЭС */
.theory-shell-kes__nav {
  max-height: none;
  overflow: visible;
}
.theory-shell-kes__nav .theory-nav-block {
  font-size: 0.78rem;
  padding: 8px 10px;
}
.theory-shell-kes__nav .theory-nav-lesson--nested {
  font-size: 0.76rem;
  padding: 6px 8px;
}
body.theory-read-mode .theory-shell-kes {
  display: none;
}

@media (max-width: 900px) {
  body.theory-page {
    --pd-sidebar: auto;
  }
  body.theory-page .site-global-sidebar.prep-dash__sidebar {
    height: auto;
    max-height: none;
    position: sticky;
  }
}

.prep-dash.use-app-shell .prep-dash__shell {
  display: block;
  min-height: 0;
}

.prep-dash.use-app-shell.prep-dash--in-diag .prep-dash__shell,
.prep-dash.use-app-shell.prep-dash--result-focus .prep-dash__shell {
  display: none;
}

/* Результат мини-теста: меню остаётся видимым */
body.use-app-shell #quizResultPanel.theory-quiz-result-panel {
  padding: 16px 20px 32px;
}

.prep-dash.use-app-shell .prep-dash__main {
  width: 100%;
  max-width: none;
}

.prep-dash.use-app-shell.prep-dash--preview .prep-dash__banner {
  left: 0;
}

/* Теория и другие страницы с app-shell */
body.use-app-shell:not(.prep-dash) .theory-layout {
  max-width: none;
  width: 100%;
}
body.use-app-shell.theory-page:not(.prep-dash) .theory-layout--content-only {
  max-width: none;
  width: 100%;
}

body.use-app-shell:not(.prep-dash) .theory-main {
  min-width: 0;
}

body.has-site-bottom-nav .theory-main {
  padding-bottom: calc(72px + env(safe-area-inset-bottom, 0));
}

/* Reference sidebar for the student product. */
body.prep-dash--v2 { --pd-sidebar: 248px; }
body.prep-dash--v2 .site-global-sidebar.prep-dash__sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  max-height: 100vh;
  padding: 24px 15px 18px;
  background: #fff;
  border-right: 1px solid #e9eeeb;
}
body.prep-dash--v2 .site-global-sidebar .prep-dash__brand {
  min-height: 54px;
  margin: 0 10px 20px;
  gap: 11px;
}
body.prep-dash--v2 .site-global-sidebar .prep-dash__brand-icon {
  width: 31px;
  height: 31px;
  color: #08a94f !important;
  background: transparent;
}
body.prep-dash--v2 .site-global-sidebar .prep-dash__brand-icon svg { fill:currentColor; width:100%; height:100%; }
body.prep-dash--v2 .site-global-sidebar .prep-dash__brand-title {
  color: #087a43;
  font-size: 20px;
  line-height: 1.1;
}
body.prep-dash--v2 .site-global-sidebar .prep-dash__brand-tag {
  margin-top: 4px;
  color: #7a8494;
  font-size: 13px;
}
body.prep-dash--v2 .site-global-sidebar .prep-dash__nav { gap: 5px; }
body.prep-dash--v2 .site-global-sidebar .prep-dash__nav a {
  min-height: 46px;
  box-sizing: border-box;
  padding: 10px 14px;
  border-radius: 12px;
  color: #1d2b42;
  font-size: 14px;
}
body.prep-dash--v2 .site-global-sidebar .prep-dash__nav a:hover { background:#f5f9f6; color:#087a43; }
body.prep-dash--v2 .site-global-sidebar .prep-dash__nav a.is-active { background:#edf8f1; color:#087a43; }
body.prep-dash--v2 .site-global-sidebar .prep-dash__nav-icon { width:20px; height:20px; }
body.prep-dash--v2 .site-app-shell-ege-wrap { margin-top:auto; padding-top:22px; }
body.prep-dash--v2 .site-shell-ege-cta {
  gap: 11px;
  padding: 15px;
  border: 1px solid #dcebe1;
  border-radius: 14px;
  color: #173e2a;
  background: linear-gradient(145deg,#f3faf5,#edf8f1);
  box-shadow: none;
}
body.prep-dash--v2 .site-shell-ege-cta:hover { border-color:#b9ddc6; box-shadow:0 4px 12px rgba(8,122,67,.08); color:#173e2a; }
body.prep-dash--v2 .site-shell-ege-cta .prep-dash__nav-icon { color:#087a43; }
body.prep-dash--v2 .prep-dash__ege-cta-text { color:#087a43; font-size:14px; }
body.prep-dash--v2 .prep-dash__ege-cta-sub { color:#78857d; font-size:11px; }
body.prep-dash--v2 .prep-dash__ege-cta-btn { min-height:40px; box-sizing:border-box; color:#fff; background:#08b958; border:0; box-shadow:none; }
body.prep-dash--v2 #siteAppShellExtras:empty { display:none; }

@media (max-width:900px) {
  body.prep-dash--v2 .site-global-sidebar.prep-dash__sidebar { height:auto;max-height:none;padding:10px 14px; }
  body.prep-dash--v2 .site-global-sidebar .prep-dash__brand { margin:0 0 8px;min-height:42px; }
  body.prep-dash--v2 .site-global-sidebar .prep-dash__nav a { min-height:40px; }
  body.prep-dash--v2 .site-app-shell-ege-wrap { display:none; }
}

/* Дневник и трофеи */
.trophy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.trophy-card {
  padding: 14px;
  border-radius: 12px;
  border: 1px solid #e2ebe6;
  background: #fff;
  text-align: center;
}

.trophy-card.is-earned {
  border-color: #a8d5ba;
  background: #f4fbf7;
}

.trophy-card.is-locked {
  opacity: 0.65;
}

.trophy-card__icon {
  font-size: 2rem;
  display: block;
  margin-bottom: 8px;
}

.trophy-grid--muted .trophy-card {
  background: #fafafa;
}

.journal-entry-card {
  padding: 12px 14px;
  margin: 10px 0;
  border-left: 3px solid #1a5f4a;
  background: #fafcfb;
  border-radius: 0 8px 8px 0;
}

.journal-entry-card time {
  font-size: 0.8rem;
  color: #888;
}

.journal-entry-prompt {
  font-weight: 600;
  color: #1a5f4a;
  margin: 6px 0;
}

.hint-text {
  color: #666;
  font-size: 0.9rem;
}

.prep-dash__achievements a {
  color: inherit;
  text-decoration: none;
}

.prep-dash__achievements a:hover {
  text-decoration: underline;
}

/* ============ Верхняя панель навигации (меню перенесено из сайдбара) ============ */
:root { --site-topbar-h: 58px; }

.site-app-topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 4px 10px;
  min-height: var(--site-topbar-h);
  padding: 6px 16px;
  background: #fff;
  border-bottom: 1px solid #e2ebe6;
  box-shadow: 0 1px 3px rgba(15, 40, 30, 0.04);
}

.site-app-topbar__brand {
  flex-shrink: 0;
  align-items: center;
}
.site-app-topbar__brand .prep-dash__brand-icon { width: 34px; height: 34px; font-size: 1.2rem; }
.site-app-topbar__brand .prep-dash__brand-title { font-size: 1rem; }
.site-app-topbar__brand .prep-dash__brand-tag { display: none; }

.site-app-topbar .site-app-shell__nav {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 2px;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.site-app-topbar .site-app-shell__nav::-webkit-scrollbar { display: none; }

.site-app-topbar .site-app-shell__nav a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  padding: 7px 9px;
  border-radius: 8px;
  white-space: nowrap;
  font-size: 0.875rem;
  color: var(--pd-text, #26332e);
  text-decoration: none;
}
.site-app-topbar .site-app-shell__nav a:hover { background: #f0f5f2; }
.site-app-topbar .site-app-shell__nav a.is-active {
  background: var(--pd-green-light, #e7f5ec);
  color: var(--pd-green, #1a5f4a);
  font-weight: 600;
}
.site-app-topbar .site-app-shell__nav a.is-disabled { opacity: 0.45; pointer-events: none; }
.site-app-topbar .prep-dash__nav-icon { width: 18px; height: 18px; opacity: 0.85; }
.site-app-topbar .nav-badge {
  background: #ef4444; color: #fff; font-size: 0.7rem; font-weight: 700;
  border-radius: 999px; padding: 1px 6px; margin-left: 2px;
}

/* «Пробный ЕГЭ» — компактной кнопкой справа */
.site-app-topbar .site-app-shell-ege-wrap { flex-shrink: 0; margin: 0; }
.site-app-topbar .prep-dash__ege-cta,
.site-app-topbar .site-shell-ege-cta {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  min-height: 34px;
  box-shadow: none;
}
.site-app-topbar .prep-dash__ege-cta-sub,
.site-app-topbar .prep-dash__ege-cta-btn,
.site-app-topbar .prep-dash__ege-cta-icon { display: none; }
.site-app-topbar .prep-dash__ege-cta-text { font-size: 0.82rem; white-space: nowrap; }

.site-app-topbar__spacer { flex: 1 1 auto; }

.site-app-topbar__user {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.86rem;
}
.site-app-topbar__login,
.site-app-topbar__reg,
.site-app-topbar__logout {
  text-decoration: none;
  white-space: nowrap;
}
.site-app-topbar__login { color: var(--pd-green, #1a5f4a); font-weight: 600; }
.site-app-topbar__reg {
  background: var(--pd-green, #16a34a);
  color: #fff;
  padding: 7px 12px;
  border-radius: 8px;
  font-weight: 600;
}
.site-app-topbar__badge {
  color: var(--pd-green, #1a5f4a);
  font-weight: 600;
  text-decoration: none;
}
.site-app-topbar__logout { color: #94766a; }
.site-app-topbar__logout:hover { color: #c62828; }

/* Пользовательский виджет теперь в общей верхней панели — не дублируем в шапке страницы */
.site-app-topbar ~ .site-app-frame .prep-dash__topbar-right .prep-dash__user,
.site-app-topbar ~ .site-app-frame .student-shell__topbar .prep-dash__user {
  display: none;
}

/* Рамка контента под верхней панелью */
.site-app-frame { min-height: calc(100vh - var(--site-topbar-h)); }

/* Боковая колонка теперь только для контента страницы (дерево КЭС, панели). */
.site-global-sidebar.prep-dash__sidebar { padding-top: 16px; }
.site-global-sidebar.prep-dash__sidebar,
body.theory-page .site-global-sidebar.prep-dash__sidebar {
  height: calc(100vh - var(--site-topbar-h));
  max-height: calc(100vh - var(--site-topbar-h));
  top: var(--site-topbar-h);
}
body.prep-dash--v2 .site-global-sidebar.prep-dash__sidebar { top: var(--site-topbar-h); }

/* Нет контента для боковой колонки → скрываем её, контент на всю ширину */
.site-app-frame--flat > aside.site-global-sidebar { display: none; }

@media (max-width: 900px) {
  .site-global-sidebar.prep-dash__sidebar,
  body.theory-page .site-global-sidebar.prep-dash__sidebar {
    height: auto;
    max-height: none;
    top: var(--site-topbar-h);
  }
}

@media (max-width: 760px) {
  .site-app-topbar { flex-wrap: wrap; gap: 6px 10px; padding: 8px 14px; }
  .site-app-topbar .site-app-shell-ege-wrap { order: 3; }
  .site-app-topbar__user { order: 2; margin-left: auto; }
  .site-app-topbar .site-app-shell__nav { order: 4; flex-basis: 100%; }
}

@media (max-width: 640px) {
  /* на телефоне навигацию берёт нижняя панель */
  body.has-site-bottom-nav .site-app-topbar .site-app-shell__nav { display: none; }
  body.has-site-bottom-nav .site-app-topbar .site-app-shell-ege-wrap { display: none; }
}
