/* Мобильные правки области "education": только внутри @media (max-width: 768px), десктоп не менять */
@media (max-width: 768px) {

  /* ---------- Вкладки и списки (index, cyclogram, планы) ---------- */
  .education-module .education-tabs-container { padding: 10px; }
  .education-module .education-main-tabs { overflow-x: auto; flex-wrap: nowrap; gap: 18px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .education-module .education-main-tabs::-webkit-scrollbar { display: none; }
  .education-module .education-main-tabs .main-tab { flex-shrink: 0; white-space: nowrap; min-height: 44px; }
  .education-module .education-tabs-container .tab-nav-item { flex-shrink: 0; white-space: nowrap; padding: 12px 14px; }
  .education-module .education-sub-tabs { gap: 6px; }
  .education-module .sub-tab-item { padding: 10px 14px; min-height: 40px; display: inline-flex; align-items: center; }
  .education-module .education-year-filter { justify-content: flex-start; flex-wrap: wrap; }
  .education-module .education-year-filter select { height: 42px; min-width: 150px; font-size: 16px; }
  .education-module .btn-create-plan { flex: 1 1 100%; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
  .education-module .education-plan-list .list-item { padding: 10px 10px 10px 8px !important; }
  .education-module .education-plan-list .item-info { min-width: 0; }
  .education-module .education-plan-list .item-title { font-size: 14px; word-break: break-word; }
  .education-module .education-plan-list .item-header { margin-bottom: 4px; }
  .education-module .education-plan-list .item-meta-compact { flex-wrap: wrap; gap: 4px 12px; }
  .education-module .education-plan-list .item-meta-field { min-width: 0; }
  .education-module .education-plan-list .list-item .action-btn { width: 40px; height: 40px; font-size: 16px; }

  /* ---------- Просмотр плана: шапка, тело, панель действий ---------- */
  .education-module .edu-view-widget .box { overflow: visible; }
  .education-module .edu-view-widget .box-header { padding: 14px; }
  .education-module .edu-view-widget .box-body { padding: 14px; }
  .education-module .edu-view-widget .box-header .box-tools { flex-wrap: wrap !important; width: 100%; gap: 8px !important; }
  .education-module .edu-view-widget .box-header .box-tools .btn { margin-left: 0; min-height: 40px; display: inline-flex; align-items: center; gap: 6px; }
  .education-module .edu-specialist-actions { flex-wrap: wrap; }
  .education-module .edu-specialist-actions .btn { flex: 1 1 auto; min-height: 44px; }
  .education-module .edu-view-widget .edu-actions-bar {
    position: sticky; bottom: 0; z-index: 20; background: #fff;
    margin: 0 -14px -14px; padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid #e3e8ef; box-shadow: 0 -4px 12px rgba(0, 0, 0, .06); gap: 8px !important;
  }
  .education-module .edu-actions-bar #dirty-actions,
  .education-module .edu-actions-bar #clean-actions { width: 100%; margin-top: 0; flex-wrap: wrap; gap: 8px; }
  .education-module .edu-actions-bar #dirty-actions .btn,
  .education-module .edu-actions-bar #clean-actions .btn { flex: 1 1 auto; width: auto !important; min-height: 44px; }
  .education-module .edu-actions-bar .btn-delete-draft { margin-left: 0; flex: 0 0 44px !important; }
  .education-module .edu-director-actions .btn { flex: 1 1 100%; min-height: 44px; }
  .education-module .edu-plan-item .actions .btn { min-width: 40px; min-height: 40px; }
  .education-module .edu-view-add-subject .btn { width: 100%; min-height: 44px; }

  /* ---------- Создание плана: нижние кнопки ---------- */
  .education-form-widget .box-footer .form-group { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }
  .education-form-widget .box-footer .form-group > .btn { flex: 1 1 calc(50% - 8px); margin: 0 !important; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
  .education-form-widget .box-footer .form-group > label.btn { flex: 1 1 100%; }
  .education-form-widget .box-footer .save-status-text { margin-left: 0 !important; flex: 1 1 100%; }

  /* ---------- Циклограмма: шапка ---------- */
  .cyclogram-header { position: relative; }
  .cyclogram-header .btn-link { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; top: 4px !important; left: 4px !important; }
  .cyclogram-header .header-info { padding-left: 44px !important; min-height: 44px; }
  .cyclogram-header .header-actions { flex-wrap: wrap; justify-content: flex-start !important; gap: 8px !important; }
  .cyclogram-header .btn-export,
  .cyclogram-header .btn-history,
  .cyclogram-header .btn-delete {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 44px; min-width: 44px; padding: 8px 14px !important; font-size: 14px !important;
  }
  .cyclogram-header .btn-export-text { display: inline; }

  /* ---------- Циклограмма: недели ---------- */
  .week-tabs { scroll-snap-type: x proximity; padding-bottom: 2px; }
  .week-tab { min-height: 44px; display: inline-flex; align-items: center; gap: 6px; font-size: 13px !important; scroll-snap-align: start; }
  .week-state-bar { flex-direction: column; align-items: flex-start; gap: 4px; }

  /* ---------- Циклограмма: таблица ---------- */
  .cyclogram-table-wrap { margin: 0 !important; padding: 0 !important; overscroll-behavior-x: contain; }
  .cyclogram-table { width: 880px !important; min-width: 880px !important; table-layout: fixed; }
  .cyclogram-table th:first-child,
  .cyclogram-table td.activity-name { width: 120px !important; min-width: 120px !important; max-width: 120px !important; box-shadow: 2px 0 4px rgba(0, 0, 0, .06); }
  .cyclogram-table th.day-col,
  .cyclogram-table td.day-cell { width: 140px !important; min-width: 140px !important; }
  .cyclogram-table th:last-child,
  .cyclogram-table td.row-actions { width: 56px !important; min-width: 56px !important; }
  .cyclogram-table td.activity-name { font-size: 12px !important; line-height: 1.3; }
  .cyclogram-table .activity-text { font-size: 12px !important; width: calc(100% - 26px) !important; }
  .cell-editable, .cell-preview { min-height: 64px !important; font-size: 12px !important; touch-action: manipulation; -webkit-tap-highlight-color: rgba(102, 126, 234, .2); }
  .cell-editable { cursor: pointer; border: 1px dashed #d5d9f5; }
  .cell-editable.filled { border-color: transparent; }
  .cell-content, .cell-preview span { font-size: 12px !important; padding: 6px; }
  .cell-content .placeholder { font-size: 11px; }

  .btn-add-general {
    float: none; display: flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; margin: 6px 0 0; font-size: 16px; line-height: 1;
    background: #4CAF50; color: #fff; opacity: 1; touch-action: manipulation; position: relative; z-index: 1;
  }
  .btn-add-general:hover { background: #43a047; }

  .row-actions { vertical-align: middle; text-align: center; }
  .row-btn { display: flex; align-items: center; justify-content: center; width: 40px !important; height: 40px !important; margin: 0 auto 6px; font-size: 16px !important; touch-action: manipulation; }
  .row-btn img { width: 22px; height: 22px; }
  .general-text-display { min-height: 36px; touch-action: manipulation; }
  .general-editor-btns .btn { min-height: 40px; min-width: 40px; }

  /* ---------- Циклограмма: редактор ячейки на весь экран ---------- */
  body:has(.cell-editable.editing) { overflow: hidden; }
  .cyclogram-table td.day-cell:has(.cell-editable.editing) { height: 72px; }
  .cell-editable.editing {
    position: fixed !important; top: 0; left: 0; right: 0; bottom: auto; height: 100vh; height: 100dvh;
    z-index: 100000; display: flex; flex-direction: column; margin: 0; padding: 0 !important;
    min-height: 0 !important; background: #fff !important; border: 0; border-radius: 0; cursor: default; overflow-y: auto;
  }
  .cell-editable.editing .cell-editor-bar {
    display: flex; align-items: center; gap: 10px; flex: 0 0 auto;
    padding: 8px 12px; background: #f8f9fa; border-bottom: 1px solid #e3e8ef;
  }
  .cell-editor-title { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; color: #333; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .cell-editor-done {
    flex: 0 0 auto; min-height: 44px; padding: 0 20px; border: 0; border-radius: 8px;
    background: #4CAF50; color: #fff; font-size: 15px; font-weight: 600; touch-action: manipulation;
  }
  .cell-editable.editing .cell-editor { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
  .cell-editable.editing .note-editor { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }
  .cell-editable.editing .note-toolbar { flex: 0 0 auto; padding: 6px !important; }
  .cell-editable.editing .note-btn { min-width: 44px; min-height: 44px; font-size: 16px !important; }
  .cell-editable.editing .note-editing-area { flex: 1 1 auto; min-height: 0 !important; height: auto !important; }
  .cell-editable.editing .note-editable { min-height: 40dvh !important; height: 100% !important; max-height: none !important; padding: 12px !important; font-size: 16px !important; line-height: 1.5 !important; }
  .cell-editable.editing .cyclogram-subject-entry { flex: 0 0 auto; margin: 8px 12px; }

  /* ---------- Циклограмма: футер, панель действий, сохранение ---------- */
  .cyclogram-footer .progress-info { flex-wrap: wrap; }
  .cyclogram-footer .progress-bar { width: 100%; }
  .cyclogram-footer { margin-bottom: 84px; }
  .cyclogram-actions-bar {
    position: fixed !important; left: 0; right: 0; bottom: 0; z-index: 1000;
    flex-direction: row !important; align-items: center; margin: 0 !important;
    padding: 8px 72px calc(8px + env(safe-area-inset-bottom, 0px)) 10px !important;
    border-radius: 12px 12px 0 0; box-shadow: 0 -3px 12px rgba(0, 0, 0, .14);
  }
  .cyclogram-actions-bar .btn-send-review { flex: 1 1 auto; width: auto !important; min-height: 44px; padding: 6px 12px; font-size: 14px; line-height: 1.2; justify-content: center; text-align: center; }
  .cyclogram-actions-bar .cyclogram-sent-hint { display: none; }
  #fixed-save-wrapper { right: 12px !important; bottom: calc(76px + env(safe-area-inset-bottom, 0px)) !important; z-index: 1001; }
  #fixed-save-wrapper .fixed-save-btn { min-height: 44px; padding: 6px 14px !important; font-size: 14px !important; }
  .cyclogram-methodist-actions .btn,
  .cyclogram-specialist-form .btn { min-height: 44px; }
  .cyclogram-specialist-form select,
  .cyclogram-specialist-form textarea { margin-bottom: 8px; }

  /* ---------- Циклограмма: модалки ---------- */
  .cyc-weeks-modal { max-height: calc(100dvh - 24px); overflow-y: auto; }
  .cyc-weeks-body { padding: 14px; }
  .cyc-weeks-item { flex-wrap: wrap; min-height: 44px; }
  .cyc-weeks-item-note { margin-left: 0; }
  .cyc-weeks-actions { flex-wrap: wrap; }
  .cyc-weeks-actions .btn { flex: 1 1 auto; min-height: 44px; }
  .history-modal-header button { min-width: 44px; min-height: 44px; }
  .ai-modal-header button { min-width: 44px; min-height: 44px; }

  /* ---------- Библиотека ---------- */
  .library { padding-bottom: 96px; }
  .library .library-title { font-size: 20px; }
  .library .library-sections { gap: 8px; margin-bottom: 12px; }
  .library .library-section { padding: 10px 12px; gap: 10px; }
  .library .library-section-icon { width: 40px; height: 40px; font-size: 17px; }
  .library .library-section-hint,
  .library .library-section-arrow { display: none; }
  .library .library-section-count { margin-top: 2px; }
  .library .library-panel { padding: 12px; }
  .library .library-toolbar { gap: 8px; }
  .library .library-search { flex: 1 1 100%; min-width: 0; }
  .library .library-search input { font-size: 16px; padding: 11px 0; }
  .library .library-select { flex: 1 1 auto; min-height: 42px; font-size: 16px; }
  .library .library-deleted-toggle { min-height: 42px; }
  .library .library-tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .library .library-tabs::-webkit-scrollbar { display: none; }
  .library .library-tab { flex-shrink: 0; white-space: nowrap; min-height: 38px; }
  .library .library-list { max-height: 72dvh; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  .library .library-row { grid-template-columns: 40px minmax(0, 1fr); gap: 8px 12px; padding: 10px; }
  .library .library-row-title { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-word; }
  .library .library-row-actions { grid-column: 1 / -1; justify-content: flex-end; gap: 8px; padding-top: 8px; border-top: 1px solid var(--lib-line); }
  .library .library-icon-btn { width: 44px; height: 44px; font-size: 16px; }
  .library .library-fab { right: 12px; bottom: calc(76px + env(safe-area-inset-bottom, 0px)); width: 56px; height: 56px; }

  .library .library-modal-overlay { padding: 0; align-items: stretch; }
  .library .library-modal { max-height: none; height: 100dvh; border-radius: 0; }
  .library .library-modal-close { top: 8px; right: 8px; width: 44px; height: 44px; z-index: 2; }
  .library .library-modal-view { padding: 12px; gap: 12px; }
  .library .library-view-head { flex-wrap: wrap; gap: 10px; padding-right: 52px; }
  .library .library-view-titles h2 { font-size: 16px; word-break: break-word; }
  .library .library-view-download { flex: 1 1 100%; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
  .library .library-view-body { gap: 12px; min-height: 0; }
  .library .library-view-frame iframe { min-height: 60dvh; height: 60dvh; }
  .library .library-view-open { width: 100%; min-height: 44px; margin-top: 10px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
  .library .library-modal-form { padding: 16px 14px; max-width: none; }
  .library .library-modal-form h2 { padding-right: 48px; }
  .library .library-form-actions { flex-wrap: wrap; }
  .library .library-form-actions .btn { flex: 1 1 auto; min-height: 44px; }
  .library .library-file-pick { min-height: 48px; word-break: break-word; }
}
