/* ===== Мобильная адаптация егэша.рф ===== */
@media (max-width: 980px) {
  html, body { overflow-x: hidden; -webkit-text-size-adjust: 100%; }
  body { font-size: 15px; }

  /* Резиновые контейнеры вместо фиксированных 1004/980px */
  #container, #site-bg, #site-bottom-bg, #footer, .forumContent {
    width: auto !important; max-width: 100% !important;
    margin-left: 0 !important; margin-right: 0 !important; box-sizing: border-box;
  }
  #all1, #all2 { width: 100% !important; height: auto !important; min-height: 0 !important; background-size: cover !important; }

  /* Шапка */
  #sitelogo {
    font-size: 24px !important; line-height: 1.2 !important; height: auto !important;
    padding: 16px 12px !important; margin-left: 0 !important; word-break: break-word;
  }
  #top { height: auto !important; overflow: hidden; }
  #today, #whois {
    float: none !important; width: auto !important; text-align: center !important;
    height: auto !important; line-height: 1.7 !important; font-size: 12px !important; margin: 0 6px !important;
  }
  #top-menu { height: auto !important; overflow: hidden; padding: 4px 0; }

  /* Колонки: контент ПЕРВЫМ, затем меню ЕГЭ, затем ОГЭ */
  #site-bg { display: flex !important; flex-direction: column; }
  #maincol { order: 1; }
  #leftcol { order: 2; }
  #rightcol { order: 3; }
  #site-bottom-bg { order: 4; display: none; }
  #leftcol, #rightcol, #maincol {
    float: none !important; width: auto !important; max-width: 100% !important;
    margin: 0 0 8px 0 !important; box-sizing: border-box;
  }
  #maincol { padding: 0 10px !important; }

  /* Боковые блоки — резиновые, чистый заголовок вместо фоновой картинки */
  .sidebar, .block, .blocktitle, .blockcontent, .blockcontent-inside {
    width: auto !important; max-width: 100% !important; box-sizing: border-box;
  }
  .sidebar { margin: 0 8px !important; font-size: 14px !important; }
  .blocktitle {
    background: #e8f4fa !important; border-left: 4px solid #219cc5 !important; border-radius: 3px;
    height: auto !important; line-height: 32px !important; margin-bottom: 6px !important;
  }
  .blocktitle-inside { margin-left: 8px !important; }
  .blockcontent-inside { margin-left: 8px !important; margin-right: 8px !important; }

  /* Контент: картинки и таблицы не вылезают за экран */
  #maincol img, .eMessage img, .eText img { max-width: 100% !important; height: auto !important; }
  #maincol table, .eMessage table, .eText table {
    max-width: 100% !important; width: auto !important; height: auto !important;
    display: block; overflow-x: auto; -webkit-overflow-scrolling: touch;
  }
  #maincol td, #maincol th { height: auto !important; }
  .eMessage, .eText, .eAnswer, .cMessage { font-size: 15px !important; line-height: 1.5 !important; }
  .eTitle { font-size: 17px !important; line-height: 1.3 !important; }

  /* Меню — крупные зоны нажатия */
  .uMenuRoot li { line-height: 1.4 !important; }
  .uMenuItem { margin: 0 !important; }
  .uMenuItem a, .blockcontent li a, .blockcontent > a { display: block; padding: 10px 4px !important; }
  .uMenuItem span { margin-left: 8px; }

  /* Поиск */
  .searchForm { width: 100%; }
  .searchForm input[type=text], .queryField {
    width: 100% !important; box-sizing: border-box; padding: 9px !important; font-size: 15px !important;
  }
  .searchForm .schBtn { margin-top: 6px; }
  .searchForm input[type=submit] { padding: 9px 18px !important; font-size: 15px !important; }

  /* Опрос (наш виджет) */
  .uPoll .ep-opt { font-size: 14px !important; padding: 4px 0; }
  .uPoll .ep-row { font-size: 13px !important; }
  .uPoll .ep-sub button { padding: 9px 18px !important; font-size: 14px !important; }

  /* Универсально — медиа по ширине экрана */
  img, iframe, video, embed, object { max-width: 100% !important; }

  /* Подвал */
  #footer { height: auto !important; padding: 8px 0; }
  #copyright, #powered_by { float: none !important; width: auto !important; text-align: center !important; margin: 4px 0 !important; line-height: 1.5 !important; }
}

@media (max-width: 520px) {
  body { font-size: 16px; }
  #sitelogo { font-size: 20px !important; padding: 12px 10px !important; }
  .eMessage, .eText, .eAnswer, .cMessage { font-size: 16px !important; }
}

/* ===== Доводка мобильной версии ===== */
@media (max-width: 980px) {
  /* выравнивание по левому краю вместо justify (на узком экране дыры между словами) */
  #maincol, #leftcol, #rightcol, .sidebar, .eMessage, .eText, .eAnswer,
  .cMessage, .blockcontent, .blockcontent-inside, td {
    text-align: left !important;
  }
  /* читаемый логотип независимо от фона-неба */
  #sitelogo {
    color: #0d5876 !important;
    text-shadow: 0 1px 1px rgba(255,255,255,0.75);
    font-weight: bold;
  }
  /* картинки в статьях — на всю ширину по центру, а не обтекание */
  #maincol img[align="left"], #maincol img[align="right"],
  .eMessage img[align], .eText img[align] {
    float: none !important; display: block; margin: 8px auto !important;
  }
  /* виджеты ВК (особенно комментарии) имеют жёсткую ширину 580-590px — вписываем в экран */
  #vk_comments, #vk_like, #vk_groups, .vk_comments, [id^="vk_"] {
    max-width: 100% !important; width: auto !important; box-sizing: border-box;
  }
  [id^="vkwidget"], iframe[id^="vkwidget"], #vk_comments iframe, #vk_groups iframe, #vk_like iframe {
    max-width: 100% !important; width: 100% !important;
  }
}

/* ===== Адаптивное видео (YouTube-вставки вместо удалённого плеера uCoz) ===== */
.ytbox { position: relative; display: block; width: 100%; max-width: 560px; margin: 8px 0; aspect-ratio: 16 / 9; background: #000; }
.ytbox iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* ===== Мобильный сайдбар (создаётся скриптом как #mSidebar) ===== */
#mSidebar { padding: 0 8px; }
#mSidebar .block, #mSidebar .sidebar { width: auto !important; max-width: 100% !important; margin: 0 0 10px !important; }
#mSidebar #vk_groups, #mSidebar #vk_groups iframe { width: 100% !important; max-width: 100% !important; }
/* свёрнутые меню-блоки: индикатор ▸/▾ в заголовке */
#mSidebar .m-acc .blocktitle { cursor: pointer; position: relative; }
#mSidebar .m-acc .blocktitle::after { content: "▸"; position: absolute; right: 12px; top: 0; color: #219cc5; }
#mSidebar .m-acc.m-open .blocktitle::after { content: "▾"; }
/* пункты меню: убрать кривые спрайт-маркеры, ровный красный треугольник слева от текста */
#mSidebar .uMenuItem a { background: none !important; padding: 10px 8px !important; display: block; line-height: 1.3 !important; }
#mSidebar .uMenuArrow { display: none !important; }
#mSidebar .uMenuItem span { margin-left: 0 !important; }
#mSidebar .uMenuItem a::before { content: "▸"; color: #d21918; font-size: 9px; margin-right: 8px; vertical-align: middle; }
#mSidebar .uMenuRoot li ul { margin-left: 16px; }
#mSidebar .uMenuRoot li { border-bottom: 1px dotted #cfe6ef; }
