/**
 * Мобильная адаптация /task12/ и /task12/{slug}/ — dock, условие, Машина Тьюринга, разбор.
 * Референс layout: ege_task1_mobile.css; логика dock: task8 (ege_task2_mobile).
 */

:root {
  --ege-task12-mobile-accent: #10b981;
  --ege-task12-mobile-accent-soft: rgba(16, 185, 129, 0.18);
  --ege-task12-mobile-dock-pad: calc(3.85rem + env(safe-area-inset-bottom, 0px));
}

@media (max-width: 768px) and (pointer: coarse) {
  body.libreoffice-page-task12.task-mobile-mode #task-sidebar {
    width: 0;
    overflow: hidden;
    pointer-events: none;
    visibility: hidden;
  }

  body.libreoffice-page-task12.task-mobile-mode #task-sidebar .task-sidebar__panel,
  body.libreoffice-page-task12.task-mobile-mode .task-sidebar__toggle {
    display: none !important;
  }

  body.libreoffice-page-task12.task-mobile-mode .task-sidebar ~ .neuroege-hf-task-root,
  body.libreoffice-page-task12.task-mobile-mode .task-sidebar--open ~ .neuroege-hf-task-root {
    margin-left: 0 !important;
    padding-left: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }

  body.libreoffice-page-task12.task-mobile-mode .neuroege-hf-task-root,
  body.libreoffice-page-task12.task-mobile-mode .neuroege-hf-task-root > .page.libreoffice-task9-page.task-solve-page {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    box-sizing: border-box;
    min-height: 100dvh;
  }

  body.libreoffice-page-task12.task-mobile-mode .neuroege-hf-task-root {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-bottom: var(--ege-task12-mobile-dock-pad);
  }

  body.libreoffice-page-task12.task-mobile-mode .neuroege-hf-task-root > .header--task-hf {
    flex: 0 0 auto;
    position: sticky;
    top: 0;
    z-index: 48;
  }

  body.libreoffice-page-task12.task-mobile-mode .neuroege-hf-task-root > .page.libreoffice-task9-page.task-solve-page {
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    padding-bottom: 0 !important;
  }

  body.libreoffice-page-task12.task-mobile-mode #hf-variants-shell-head-hit {
    display: none !important;
  }

  body.libreoffice-page-task12.task-mobile-mode .libreoffice-task9-page.task-solve-page {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-rows: minmax(0, 1fr) !important;
    column-gap: 0 !important;
    min-height: 0;
    overflow: hidden;
  }

  body.libreoffice-page-task12.task-mobile-mode .libreoffice-task9-col-resizer {
    display: none !important;
  }

  body.libreoffice-page-task12.task-mobile-mode #task-answer-section {
    display: none !important;
  }

  body.libreoffice-page-task12.task-mobile-mode #mobile-immersive-hint,
  body.libreoffice-page-task12.task-mobile-mode .neuroege-ai-chat__fab {
    display: none !important;
  }

  body.libreoffice-page-task12.task-mobile-mode.ege-task12-ai-chat-open {
    overflow: hidden;
  }

  body.libreoffice-page-task12.task-mobile-mode.task-mobile-pane-statement .task-solve-main {
    display: none !important;
  }

  body.libreoffice-page-task12.task-mobile-mode .task-solve__right {
    display: flex !important;
    flex-direction: column;
    grid-column: 1 / -1 !important;
    grid-row: 1 !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0;
    min-height: 0;
    margin: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    box-sizing: border-box;
    overflow: hidden;
  }

  body.libreoffice-page-task12.task-mobile-mode.task-mobile-pane-statement .task-solve__right {
    height: 100%;
    padding-bottom: calc(3.65rem + env(safe-area-inset-bottom, 0px));
    box-sizing: border-box;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  body.libreoffice-page-task12.task-mobile-mode.task-mobile-pane-trainer
    .task-solve-page,
  body.libreoffice-page-task12.task-mobile-mode.task-mobile-pane-video
    .task-solve-page {
    grid-template-rows: auto minmax(0, 1fr) !important;
  }

  body.libreoffice-page-task12.task-mobile-mode.task-mobile-pane-trainer
    .task-solve__right,
  body.libreoffice-page-task12.task-mobile-mode.task-mobile-pane-video
    .task-solve__right {
    display: flex !important;
    flex: 0 0 auto;
    grid-column: 1 / -1 !important;
    grid-row: 1 !important;
    height: auto !important;
    min-height: 0;
    overflow: visible;
    padding-bottom: 0;
  }

  body.libreoffice-page-task12.task-mobile-mode.task-mobile-pane-trainer
    .task-solve__right
    > :not(.hf-variants-shell):not(.hf-variants-shell--body),
  body.libreoffice-page-task12.task-mobile-mode.task-mobile-pane-video
    .task-solve__right
    > :not(.hf-variants-shell):not(.hf-variants-shell--body) {
    display: none !important;
  }

  body.libreoffice-page-task12.task-mobile-mode.task-mobile-pane-trainer
    .task-solve-main,
  body.libreoffice-page-task12.task-mobile-mode.task-mobile-pane-video
    .task-solve-main {
    grid-row: 2 !important;
  }

  body.libreoffice-page-task12.task-mobile-mode .task-solve-main {
    grid-column: 1 / -1 !important;
    grid-row: 1 !important;
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-left: 0;
    padding-right: 0;
  }

  body.libreoffice-page-task12.task-mobile-mode #libreoffice-task9-statement-wrap {
    flex: 0 0 auto;
    min-height: 0;
    overflow: visible;
    width: 100%;
    max-width: none;
    margin-left: 0;
    margin-right: 0;
    box-sizing: border-box;
  }

  body.libreoffice-page-task12.task-mobile-mode.task-mobile-pane-statement #libreoffice-task9-statement-wrap:not([hidden]) {
    flex: 0 0 auto;
    display: block;
  }

  body.libreoffice-page-task12.task-mobile-mode.task-mobile-pane-statement #libreoffice-task9-statement-wrap[hidden] {
    display: none !important;
  }

  body.libreoffice-page-task12.task-mobile-mode .task-solve__right > .hf-variants-shell,
  body.libreoffice-page-task12.task-mobile-mode .task-solve__right > .neuroege-hf-trainer-intro,
  body.libreoffice-page-task12.task-mobile-mode .task-solve__right > #libreoffice-task9-statement-wrap {
    width: 100%;
    max-width: none;
    margin-left: 0;
    margin-right: 0;
    box-sizing: border-box;
  }

  body.libreoffice-page-task12.task-mobile-mode .task-solve__right > .hf-variants-shell--body {
    width: 100%;
    max-width: none;
    margin-left: 0;
    margin-right: 0;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  body.libreoffice-page-task12.task-mobile-mode .libreoffice-task9-statement-scroll-inner {
    width: 100%;
    max-width: none;
  }

  body.libreoffice-page-task12.task-mobile-mode.task-mobile-pane-statement .task-wysiwyg--premium.task-statement,
  body.libreoffice-page-task12.task-mobile-mode.task-mobile-pane-statement .task12-statement.task-wysiwyg--premium {
    width: 100%;
    max-width: none;
    box-sizing: border-box;
    padding: 0.7rem 0.55rem 0.8rem;
    border-radius: 0;
    font-size: 0.9375rem;
    line-height: 1.55;
  }

  body.libreoffice-page-task12.task-mobile-mode .task-solve__left,
  body.libreoffice-page-task12.task-mobile-mode #sandbox-view,
  body.libreoffice-page-task12.task-mobile-mode .task1-hf-left-stack {
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  body.libreoffice-page-task12.task-mobile-mode.task-mobile-pane-trainer .task1-hf-left-stack {
    gap: 0.45rem;
    padding: 0.35rem 0.35rem 0.5rem;
    box-sizing: border-box;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  body.libreoffice-page-task12.task-mobile-mode.task-mobile-pane-trainer .mt-card {
    flex: 0 0 auto;
    min-height: 0;
    padding: 0.85rem 0.75rem 1rem;
    margin-bottom: 0;
  }

  body.libreoffice-page-task12.task-mobile-mode.task-mobile-pane-trainer .mt-card--tape {
    flex: 0 0 auto;
    min-height: min(42vh, 320px);
  }

  body.libreoffice-page-task12.task-mobile-mode.task-mobile-pane-trainer .mt-card--program {
    flex: 1 1 auto;
    min-height: min(38vh, 280px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  body.libreoffice-page-task12.task-mobile-mode.task-mobile-pane-trainer .mt-card__title {
    font-size: 0.95rem;
    margin-bottom: 0.35rem;
  }

  body.libreoffice-page-task12.task-mobile-mode.task-mobile-pane-trainer .mt-tape-input-row {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.65rem !important;
  }

  body.libreoffice-page-task12.task-mobile-mode.task-mobile-pane-trainer .mt-toggles-row {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.55rem !important;
  }

  body.libreoffice-page-task12.task-mobile-mode.task-mobile-pane-trainer .mt-tape-actions-row {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.45rem !important;
  }

  body.libreoffice-page-task12.task-mobile-mode.task-mobile-pane-trainer .mt-toolbar {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  body.libreoffice-page-task12.task-mobile-mode.task-mobile-pane-trainer .mt-btn {
    min-height: 2.45rem;
    touch-action: manipulation;
  }

  body.libreoffice-page-task12.task-mobile-mode.task-mobile-pane-trainer .mt-program-wrap {
    flex: 1 1 auto;
    min-height: 120px;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  body.libreoffice-page-task12.task-mobile-mode.task-mobile-pane-trainer .mt-program-table {
    font-size: 0.82rem;
  }

  body.libreoffice-page-task12.task-mobile-mode.task-mobile-pane-trainer .mt-tape-viewport {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  body.libreoffice-page-task12.task-mobile-mode.task-mobile-pane-video .task-solve-main {
    display: flex !important;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
  }

  body.libreoffice-page-task12.task-mobile-mode.task-mobile-pane-video .task-solve__left {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  body.libreoffice-page-task12.task-mobile-mode.task-mobile-pane-video #sandbox-view {
    display: none !important;
  }

  body.libreoffice-page-task12.task-mobile-mode.task-mobile-pane-video #video-view {
    flex: 1 1 auto;
    min-height: 0;
    display: flex !important;
    flex-direction: column;
    overflow: hidden;
  }

  body.libreoffice-page-task12.task-mobile-mode
    .neuroege-ai-chat--oge-task1-mobile-sheet {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    top: var(--oge-task1-ai-chat-top, 0px) !important;
    bottom: var(--oge-task1-ai-chat-bottom, 0px) !important;
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    z-index: 10140;
    align-items: stretch;
  }

  body.libreoffice-page-task12.task-mobile-mode
    .neuroege-ai-chat--oge-task1-mobile-sheet
    .neuroege-ai-chat__panel {
    width: 100% !important;
    max-width: none !important;
    height: 100% !important;
    max-height: none !important;
    border-radius: 1rem 1rem 0 0;
    box-sizing: border-box;
  }

  body.libreoffice-page-task12.task-mobile-mode
    .neuroege-ai-chat--oge-task1-mobile-sheet
    .neuroege-ai-chat__resize-handle {
    display: none !important;
  }

  body.libreoffice-page-task12.task-mobile-mode .ege-task12-variants-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.45rem 0.65rem;
    border: none;
    border-bottom: 1px solid rgba(16, 185, 129, 0.18);
    background: rgba(16, 185, 129, 0.08);
    color: inherit;
    font: inherit;
    font-size: 0.8125rem;
    font-weight: 700;
    cursor: pointer;
    touch-action: manipulation;
  }

  body.libreoffice-page-task12.task-mobile-mode:not(.ege-task12-variants-open) .hf-variants-shell #hf-variants-nav {
    display: none !important;
  }

  body.libreoffice-page-task12.task-mobile-mode:not(.ege-task12-variants-open) #hf-variants-panel-resizer {
    display: none !important;
  }

  body.libreoffice-page-task12.task-mobile-mode .hf-variants-shell__toggle {
    display: none !important;
  }

  body.libreoffice-page-task12.task-mobile-mode .task12-short-statement__toggle {
    min-height: 2.45rem;
    touch-action: manipulation;
  }
}

body.libreoffice-page-task12 .ege-task1-header-burger-wrap {
  display: none;
}

@media (max-width: 768px) and (pointer: coarse) {
  body.libreoffice-page-task12.task-mobile-mode .ege-task1-header-burger-wrap {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    margin-left: 0.25rem;
  }

  body.libreoffice-page-task12.task-mobile-mode .hf-variants-shell__head-main {
    min-width: 0;
    flex: 1 1 auto;
  }

  body.libreoffice-page-task12.task-mobile-mode .header__task-command-back,
  body.libreoffice-page-task12.task-mobile-mode .hf-variants-shell__task-arrow {
    display: none !important;
  }

  body.libreoffice-page-task12.task-mobile-mode .hf-variants-shell__exam-chip {
    display: inline-flex;
  }
}

body.libreoffice-page-task12.task-mobile-mode #task-mobile-dock {
  display: none !important;
}

.ege-task12-mobile-dock {
  border-top-color: rgba(16, 185, 129, 0.32);
  background: linear-gradient(180deg, rgba(18, 28, 24, 0.97) 0%, rgba(10, 16, 14, 0.99) 100%);
}

.ege-task12-mobile-dock .kumir-mobile-dock__panes {
  gap: 0.2rem;
}

.ege-task12-mobile-dock .kumir-mobile-dock__btn {
  flex: 1 1 0;
  min-width: 0;
  font-size: 0.5625rem;
  padding: 0.28rem 0.1rem;
}

.ege-task12-mobile-dock .kumir-mobile-dock__label {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

[data-theme="light"] .ege-task12-mobile-dock {
  border-top-color: rgba(16, 185, 129, 0.22);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(236, 253, 245, 0.99) 100%);
}

.ege-task12-mobile-dock .kumir-mobile-dock__btn--active {
  border-color: rgba(16, 185, 129, 0.55);
  background: rgba(16, 185, 129, 0.16);
  color: #a7f3d0;
}

[data-theme="light"] .ege-task12-mobile-dock .kumir-mobile-dock__btn--active {
  border-color: rgba(5, 150, 105, 0.35);
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
}

.ege-task12-mobile-dock__btn--ai.kumir-mobile-dock__btn--active {
  border-color: rgba(167, 139, 250, 0.55);
  background: rgba(167, 139, 250, 0.16);
  color: #ddd6fe;
}

body.ege-task12-header-menu-open {
  overflow: hidden;
}
