/* КРИТИЧЕСКИЕ ДЕФОЛТНЫЕ СТИЛИ (защита при медленном соединении / до загрузки Tailwind) */
.hidden { display: none !important; }
svg { max-width: 100%; }

/* Фиксация логотипа и бейджей шапки до компиляции Tailwind */
header .w-9, header .w-10 {
  width: 36px !important;
  height: 36px !important;
  min-width: 36px !important;
  min-height: 36px !important;
  flex-shrink: 0 !important;
}
header svg {
  width: 100% !important;
  height: 100% !important;
  max-width: 36px !important;
  max-height: 36px !important;
}

*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg-deep: #06000f;
  --bg-surface: #100b21;
  --bg-card: #150f2b;
  --border-subtle: #291a4f;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent-purple: #a855f7;
  --code-bg: #080512;
  --font-code: "JetBrains Mono", Consolas, monospace;
  --font-ui: "Plus Jakarta Sans", sans-serif;
}

body {
  position: relative;
  background-color: var(--bg-deep);
  color: var(--text-main);
  font-family: var(--font-ui);
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: 
    radial-gradient(ellipse at 50% -10%, rgba(126, 34, 206, 0.22) 0%, transparent 60%),
    radial-gradient(ellipse at 50% 110%, rgba(192, 132, 252, 0.14) 0%, transparent 60%);
  z-index: 0;
  pointer-events: none;
}

.font-mono { font-family: var(--font-code); }

@media (hover: none) {
  .chat-message-delete { opacity: 1; }
}

* {
  scrollbar-width: thin;
  scrollbar-color: #7e22ce #100b21;
}
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: #100b21; border-radius: 999px; }
*::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #c084fc, #7e22ce);
  border: 2px solid #100b21;
  border-radius: 999px;
}
*::-webkit-scrollbar-thumb:hover { background: #d8b4fe; }

canvas#bg-canvas,
.canvas-3d-bg {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  z-index: 1; pointer-events: none;
}

.site-content { position: relative; z-index: 10; }

/* Тренажер печати */
.code-container { display: flex; flex-direction: column; white-space: pre; font-family: var(--font-code); font-size: 0.95rem; line-height: 1.75; }
.code-line { display: flex; min-height: 1.75em; padding: 0 0.5rem; border-radius: 4px; }
.code-line.current-line { background: rgba(168, 85, 247, 0.15); }
.line-number { width: 44px; color: #64748b; text-align: right; padding-right: 1.1rem; user-select: none; font-size: 0.82rem; font-weight: 700; }
.line-content { flex: 1; word-break: break-all; }
.code-char { position: relative; display: inline; }
.code-char.ghost { color: #64748b; opacity: 0.55; }
.code-char.correct { color: #a855f7; text-shadow: 0 0 10px rgba(168, 85, 247, 0.5); font-weight: 700; }
.code-char.error { color: #ffffff; background: #ef4444; border-radius: 2px; }
.code-char.cursor::before {
  content: ""; position: absolute; left: 0; top: 15%; height: 70%; width: 2.5px;
  background: #c084fc; box-shadow: 0 0 12px #c084fc; animation: blinkCursor 0.9s infinite;
}
@keyframes blinkCursor { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

/* Клавиатура */
.kbd-board-canvas { display: flex; flex-direction: column; gap: 5px; user-select: none; }
.kbd-board-row { display: flex; gap: 5px; justify-content: center; }
.kbd-key-cap {
  background: #171030; border: 1px solid #362463; border-radius: 7px;
  height: 42px; min-width: 40px; padding: 3px 6px; color: #f1f5f9; font-family: var(--font-code); font-size: 0.78rem; font-weight: 700;
  display: flex; flex-direction: column; justify-content: space-between; align-items: center; box-shadow: 0 2px 0 #070311;
}
.kbd-key-cap.active-target {
  background: #7e22ce !important; border-color: #d8b4fe !important; color: #ffffff !important;
  box-shadow: 0 0 16px rgba(168, 85, 247, 0.9) !important; transform: translateY(-2px);
}
.kbd-key-cap.active-shift {
  background: #c026d3 !important; border-color: #f472b6 !important; color: #ffffff !important;
  box-shadow: 0 0 16px rgba(217, 70, 239, 0.9) !important; transform: translateY(-2px);
}

/* СТИЛИ ОФОРМЛЕНИЯ СТАТЕЙ */
#art-read-body img {
  max-width: 100%;
  height: auto;
  border-radius: 14px;
  margin: 20px auto;
  display: block;
  border: 1px solid #3d2772;
  box-shadow: 0 10px 30px rgba(0,0,0,0.6), 0 0 25px rgba(168, 85, 247, 0.25);
}
#art-read-body h1, #art-read-body h2, #art-read-body h3, #art-read-body h4 {
  color: #ffffff;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-top: 1.6em;
  margin-bottom: 0.6em;
  line-height: 1.3;
}
#art-read-body h1 { font-size: 1.85rem; border-bottom: 2px solid #291a4f; padding-bottom: 8px; }
#art-read-body h2 { font-size: 1.5rem; color: #e0aaff; }
#art-read-body h3 { font-size: 1.25rem; color: #c084fc; }
#art-read-body p { margin-bottom: 1.2em; line-height: 1.8; color: #cbd5e1; font-size: 1rem; }
#art-read-body ul, #art-read-body ol { margin: 1em 0 1.5em 1.5em; color: #cbd5e1; line-height: 1.75; }
#art-read-body ul { list-style-type: disc; }
#art-read-body ol { list-style-type: decimal; }
#art-read-body li { margin-bottom: 0.4em; }
#art-read-body code:not(pre code) {
  background: #171030; border: 1px solid #362463; padding: 3px 8px; border-radius: 6px;
  font-family: var(--font-code); color: #c084fc; font-size: 0.88em;
}
#art-read-body pre {
  background: #080512; border: 1px solid #291a4f; border-radius: 12px;
  padding: 16px; margin: 20px 0; overflow-x: auto; box-shadow: inset 0 2px 8px rgba(0,0,0,0.6);
}
#art-read-body pre code { color: #f1f0f7; font-family: var(--font-code); font-size: 0.88rem; line-height: 1.6; }
#art-read-body blockquote {
  border-left: 4px solid #a855f7; background: rgba(168, 85, 247, 0.08);
  padding: 14px 20px; margin: 20px 0; border-radius: 0 12px 12px 0; color: #e2e8f0; font-style: italic;
}
#art-read-body table { width: 100%; border-collapse: collapse; margin: 24px 0; font-size: 0.92rem; border-radius: 12px; overflow: hidden; border: 1px solid #291a4f; }
#art-read-body th { background: #171030; color: #c084fc; text-align: left; padding: 12px 16px; font-family: var(--font-code); font-weight: 700; border-bottom: 2px solid #291a4f; }
#art-read-body td { padding: 12px 16px; border-bottom: 1px solid #1f143a; color: #cbd5e1; }
#art-read-body tr:hover { background: rgba(168, 85, 247, 0.05); }

/* ШАХМАТНАЯ ДОСКА */
.chess-board {
  display: grid;
  grid-template-columns: repeat(8, 48px);
  grid-template-rows: repeat(8, 48px);
  border: 3px solid #7e22ce;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 0 30px rgba(126, 34, 206, 0.4);
  user-select: none;
}
.chess-square {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}
.chess-square.light { background-color: #27164f; }
.chess-square.dark { background-color: #0f0724; }
.chess-square.selected { background-color: #7e22ce !important; box-shadow: inset 0 0 12px #d8b4fe; }
.chess-square.valid-move::after {
  content: "";
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(192, 132, 252, 0.7);
  box-shadow: 0 0 8px #c084fc;
  position: absolute;
}
.chess-square.valid-capture,
.chess-square.valid-capture.last-move {
  background-color: rgba(220, 38, 38, 0.45) !important;
  box-shadow: inset 0 0 16px rgba(239, 68, 68, 0.85) !important;
}
.chess-square.valid-capture::after {
  content: "";
  position: absolute;
  inset: 4px;
  border: 3.5px solid #ef4444;
  border-radius: 50%;
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.9), inset 0 0 8px rgba(239, 68, 68, 0.5);
  pointer-events: none;
  animation: pulse-capture 1.3s infinite ease-in-out;
}
@keyframes pulse-capture {
  0%, 100% { transform: scale(1); opacity: 0.95; box-shadow: 0 0 10px rgba(239, 68, 68, 0.9); }
  50% { transform: scale(1.05); opacity: 1; box-shadow: 0 0 18px #ef4444, inset 0 0 10px #ef4444; }
}
.chess-square.last-move {
  background-color: rgba(168, 85, 247, 0.32) !important;
  box-shadow: inset 0 0 10px rgba(216, 180, 254, 0.45);
}
.chess-square.ai-hint {
  background-color: rgba(16, 185, 129, 0.35) !important;
  box-shadow: inset 0 0 14px #10b981 !important;
  border: 1.5px solid #34d399;
}

/* ПОЛЗУНОК-ПЕРЕКЛЮЧАТЕЛЬ */
.switch-toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}
.switch-toggle input { opacity: 0; width: 0; height: 0; }
.switch-slider {
  position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
  background-color: #2a1b4d; transition: .3s; border-radius: 24px; border: 1px solid #4a2f85;
}
.switch-slider:before {
  position: absolute; content: ""; height: 16px; width: 16px; left: 3px; bottom: 3px;
  background-color: #94a3b8; transition: .3s; border-radius: 50%;
}
input:checked + .switch-slider { background-color: #7e22ce; border-color: #c084fc; }
input:checked + .switch-slider:before { transform: translateX(20px); background-color: #ffffff; box-shadow: 0 0 8px #c084fc; }
input:disabled + .switch-slider { opacity: 0.4; cursor: not-allowed; }

@keyframes penaltyFlash {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); background-color: rgba(239, 68, 68, 0.4); border-color: #ef4444; }
}
.penalty-flash { animation: penaltyFlash 0.5s ease-in-out; }

.tab-pane-enter { animation: tabPaneEnter 0.24s ease-out both; }
@keyframes tabPaneEnter {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}

.deleted-image-badge {
  min-height: 5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  color: #fca5a5;
  background: rgba(69, 10, 10, 0.45);
  border: 1px solid rgba(239, 68, 68, 0.4);
  border-radius: 0.75rem;
  font: 0.75rem var(--font-code);
  text-align: center;
}

@media (max-width: 900px) {
  #chat-input-form {
    gap: 0.375rem;
    padding: 0.5rem;
  }
  #chat-msg-input {
    min-width: 0;
    flex: 1 1 0%;
  }
  #chat-input-form > button {
    padding-inline: 0.625rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tab-pane-enter { animation: none; }
}

@media (max-width: 640px) {
  .site-content > header {
    padding: 0.625rem 0.75rem;
  }
  .site-content > header > div {
    gap: 0.5rem;
  }
  #header-actions {
    width: auto;
    justify-content: flex-end;
    gap: 0.3rem;
    flex-wrap: nowrap !important;
  }
  #header-actions > button {
    min-height: 2.15rem;
    padding-inline: 0.5rem;
  }

  .site-content > main {
    padding: 1rem 0.75rem;
  }
  #auth-box {
    margin-block: 1.25rem;
    padding: 1.25rem;
  }
  #student-view > div:first-child,
  #teacher-view > div:first-child {
    align-items: stretch;
  }
  #student-view > div:first-child h2,
  #teacher-view > div:first-child h2 {
    font-size: 1.375rem;
    line-height: 1.3;
  }
  #teacher-view [id^="tt-tab-"] {
    min-width: 0;
    min-height: 2.75rem;
    white-space: normal;
    line-height: 1.25;
  }
  #student-view > div:first-child > div:last-child {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  #student-view > div:first-child > div:last-child > button {
    min-width: 0;
    min-height: 2.75rem;
    padding: 0.5rem;
    line-height: 1.25;
  }

  #tt-pane-quiz,
  #tt-pane-typing,
  #tt-pane-articles,
  #tt-pane-routes,
  #tt-pane-media,
  #tt-pane-review,
  #tt-pane-coding {
    padding: 1rem;
  }
  #tt-pane-dash,
  #tt-pane-users,
  #tt-pane-manage,
  #tt-pane-review {
    min-width: 0;
  }
  #tt-pane-dash table,
  #tt-pane-users table,
  #tt-pane-manage table,
  #tt-pane-review table,
  #student-pane-results table {
    min-width: 640px;
  }
  #student-pane-results {
    overflow-x: auto;
  }

  #quiz-runner-modal,
  #code-editor-modal,
  #code-review-modal {
    padding: 0.5rem;
  }
  #quiz-runner-modal > div {
    max-height: calc(100dvh - 1rem);
    padding: 1rem;
  }
  #code-editor-modal > div,
  #code-review-modal > div {
    width: 100%;
    height: calc(100dvh - 1rem);
    max-height: calc(100dvh - 1rem);
    padding: 0.75rem;
    border-radius: 1rem;
  }
  #code-editor-modal > div > div:nth-child(2) {
    flex-wrap: wrap;
  }
  #manual-quiz-review-modal > div {
    max-height: calc(100dvh - 1rem);
    padding: 1rem;
  }

  #chat-hub-modal {
    padding: 0;
  }
  #chat-hub-modal > div:not(#chat-drop-zone-overlay) {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
    border-width: 0;
    padding: 0.75rem;
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
  }
  #chat-hub-modal h3 {
    font-size: 1rem;
    line-height: 1.3;
  }
  #chat-layout {
    min-height: 0;
    flex-direction: column;
    gap: 0.5rem;
  }
  #chat-sidebar {
    width: 100%;
    min-width: 0;
    max-height: 9.5rem;
    flex: 0 0 auto;
    padding: 0.5rem;
  }
  #chat-sidebar > span {
    display: none;
  }
  #chat-contacts-list {
    min-height: 0;
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 0.375rem;
  }
  #chat-contacts-list > * {
    min-width: 8rem;
    max-width: 12rem;
  }
  #chat-conversation {
    min-height: 0;
    flex: 1 1 auto;
  }
  #chat-messages-container {
    min-height: 0;
    padding: 0.625rem;
  }
  #chat-input-form {
    gap: 0.375rem;
    padding: 0.5rem;
  }
  #chat-input-form > button {
    min-width: 2.5rem;
    min-height: 2.5rem;
    justify-content: center;
    padding-inline: 0.625rem;
  }
  #chat-msg-input {
    min-width: 0;
    padding-inline: 0.625rem;
  }

  #games-hub-modal > div {
    max-height: 100vh;
    max-height: 100dvh;
    padding: 1rem;
    border-radius: 1rem;
  }
  #game-view-tetris {
    gap: 1rem;
  }
  #tetris-play-area {
    flex-direction: column;
    align-items: center;
  }
  #tetris-canvas {
    width: min(62vw, 240px);
    height: auto;
  }
  #tetris-controls {
    width: min(100%, 15rem);
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  #tetris-controls > div:last-of-type {
    grid-column: 1 / -1;
  }
  #tetris-next-canvas {
    max-width: 5rem;
  }
  #chess-board-shell {
    width: 100%;
    max-width: min(calc(100vw - 2rem), 390px);
  }
  .chess-board {
    width: 100%;
    max-width: 100%;
    aspect-ratio: 1;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    grid-template-rows: repeat(8, minmax(0, 1fr));
  }
  .chess-square {
    width: 100%;
    height: 100%;
    font-size: clamp(1.25rem, 8vw, 2.2rem);
    touch-action: manipulation;
  }
}

/* Список учеников: эффект растворения/размытия при скролле */
.journal-fade-list {
  mask-image: linear-gradient(to bottom, black calc(100% - 48px), transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, black calc(100% - 48px), transparent 100%);
}


/* ==========================================================================
   MOBILE & TOUCH OPTIMIZATION (STUDENT & TEACHER SUITE)
   ========================================================================== */

/* 1. Touch controls on Canvas for Pong */
.pong-touch-btn {
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  
}

@media (max-width: 768px) {
  /* Modals full height with safe area */
  #cyber-shop-modal,
  #achievements-modal,
  #teacher-report-modal,
  #game-preview-modal,
  #games-hub-modal,
  #ai-typing-gen-modal,
  #ai-quiz-gen-modal,
  #cyber-profile-modal {
    padding: 0.25rem !important;
  }

  #cyber-shop-modal > div,
  #achievements-modal > div,
  #teacher-report-modal > div,
  #game-preview-modal > div,
  #ai-typing-gen-modal > div,
  #ai-quiz-gen-modal > div,
  #cyber-profile-modal > div {
    max-height: 98dvh !important;
    height: auto !important;
    padding: 1rem 0.85rem !important;
    border-radius: 1.25rem !important;
  }

  /* Shop color forge responsiveness */
  #shop-pane-catalog .p-4 {
    padding: 0.85rem !important;
  }

  /* Table horizontally scrollable on mobile */
  #report-students-table-body td,
  #teacher-report-modal th {
    padding: 0.5rem 0.4rem !important;
    font-size: 11px !important;
    white-space: nowrap;
  }

  /* Pong field mobile scaling */
  #pong-playfield {
    width: 100% !important;
    max-width: 100% !important;
  }

  #pong-canvas {
    width: 100% !important;
    height: auto !important;
    touch-action: none;
  }

  /* Teacher Cheat Slider on mobile */
  #teacher-pong-cheat-panel {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.5rem !important;
    padding: 0.65rem 0.85rem !important;
  }

  #teacher-pong-cheat-panel > div:last-of-type {
    max-width: 100% !important;
  }

  /* Touch controls under Pong */
  #pong-mobile-touch-controls {
    display: flex !important;
  }

  /* Teacher navigation tabs 2 cols */
  #teacher-view .grid-cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 0.4rem !important;
  }

  #teacher-view button[id^="tt-tab-"] {
    padding: 0.5rem 0.25rem !important;
    font-size: 11px !important;
    text-align: center !important;
  }

  /* Teacher journal split screen on mobile */
  #tt-pane-dash > div {
    height: auto !important;
    max-height: none !important;
    min-height: 0 !important;
  }

  #tt-pane-dash .lg\:col-span-4 {
    max-height: 280px !important;
  }

  /* Student navigation header buttons */
  #student-view > div:first-child > div:last-child {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 0.35rem !important;
  }

  #student-view > div:first-child > div:last-child > button {
    flex: 1 1 calc(50% - 0.35rem) !important;
    padding: 0.5rem 0.35rem !important;
    font-size: 11px !important;
    text-align: center !important;
  }
}


/* --- Additional Mobile Optimization for Teacher & Student --- */
@media (max-width: 768px) {
  /* Safe area padding for mobile notches */
  body {
    padding-bottom: env(safe-area-inset-bottom, 1rem);
  }

  /* Form grids responsive stacking on phones */
  #tt-pane-quiz .grid-cols-2,
  #tt-pane-typing .grid-cols-2,
  #tt-pane-articles .grid-cols-2,
  #quiz-form .grid-cols-2 {
    grid-template-columns: 1fr !important;
  }

  /* Teacher journal search & filters wrap cleanly */
  #journal-submission-search,
  #journal-task-type-filter {
    width: 100% !important;
  }

  /* Teacher report table cell sizing */
  #teacher-subs-rows td,
  #tt-pane-dash th {
    padding: 0.5rem 0.4rem !important;
    font-size: 11px !important;
  }

  /* Compact buttons in header */
  #header-actions {
    flex-wrap: wrap;
    gap: 0.35rem !important;
  }
}

/* --- Global Mobile Modals & Touch Optimization --- */
html {
  overflow-x: hidden;
  max-width: 100vw;
  -webkit-tap-highlight-color: transparent;
}

#cyber-shop-modal,
#cyber-profile-modal,
#points-history-modal,
#achievements-modal,
#teacher-report-modal,
#game-preview-modal,
#games-hub-modal,
#ai-typing-gen-modal,
#ai-quiz-gen-modal {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

#cyber-shop-modal .overflow-y-auto,
#cyber-profile-modal .overflow-y-auto,
#points-history-modal .overflow-y-auto,
.custom-scroll {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

@media (max-width: 640px) {
  #cyber-shop-modal > div,
  #cyber-profile-modal > div,
  #points-history-modal > div {
    max-height: 94dvh !important;
    width: 96% !important;
    margin: auto !important;
  }

  button, select, input, a {
    touch-action: manipulation;
  }
}

/* Cyber Header Menu Animation */
#cyber-header-menu {
  animation: cyberMenuSlideDown 0.18s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes cyberMenuSlideDown {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* --- Оптимизация для слабого интернета и режима экономии трафика --- */
.data-saver-active .canvas-3d-bg {
  display: none !important;
}

.data-saver-active * {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

#network-top-loader {
  transition: width 0.3s ease, opacity 0.3s ease;
}

#network-status-widget {
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
}



/* Кибер-тумблер переключателя режима экономии трафика */
.cyber-toggle {
  position: relative !important;
  width: 44px !important;
  height: 24px !important;
  min-width: 44px !important;
  min-height: 24px !important;
  max-height: 24px !important;
  border-radius: 9999px !important;
  background-color: #1e1538 !important;
  border: 1.5px solid #4a3575 !important;
  cursor: pointer !important;
  transition: all 0.25s ease !important;
  flex-shrink: 0 !important;
  display: inline-block !important;
  box-sizing: border-box !important;
}
.cyber-toggle::after {
  content: '' !important;
  position: absolute !important;
  top: 2px !important;
  left: 2px !important;
  width: 17px !important;
  height: 17px !important;
  border-radius: 9999px !important;
  background-color: #94a3b8 !important;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5) !important;
}
.cyber-toggle.active {
  background: linear-gradient(135deg, #7e22ce, #9333ea) !important;
  border-color: #c084fc !important;
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.6) !important;
}
.cyber-toggle.active::after {
  transform: translateX(20px) !important;
  background-color: #ffffff !important;
  box-shadow: 0 0 8px #ffffff !important;
}

/* ==========================================================================
   ПОЛНАЯ МОБИЛЬНАЯ ОПТИМИЗАЦИЯ ДЛЯ УЧИТЕЛЯ И УЧЕНИКА (v106)
   ========================================================================== */

/* На сенсорных экранах кнопка удаления сообщения в чате всегда видна */
@media (hover: none), (max-width: 768px) {
  .chat-message-delete {
    opacity: 0.85 !important;
  }
}

@media (max-width: 1023px) {
  /* Вторая строка шапки для статистики учителя на планшетах и телефонах */
  #u-stats.flex {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.375rem;
    width: 100%;
  }
  #u-stats > div {
    padding: 0.25rem 0.35rem !important;
    min-width: 0;
    text-align: center;
  }
  #u-stats > div span:first-child {
    font-size: 8px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }
  #u-stats > div span:last-child {
    font-size: 11px !important;
  }
}

@media (max-width: 768px) {
  /* --- Оптимизация Мессенджера SIDUS на мобильных --- */
  #chat-hub-modal {
    padding: 0 !important;
  }
  #chat-hub-modal > div:not(#chat-drop-zone-overlay) {
    width: 100% !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    border-width: 0 !important;
    padding: 0.5rem 0.625rem !important;
    padding-bottom: max(0.5rem, env(safe-area-inset-bottom)) !important;
  }
  #chat-hub-modal > div:not(#chat-drop-zone-overlay) > div:first-of-type {
    padding-bottom: 0.45rem !important;
  }
  #chat-hub-modal > div:not(#chat-drop-zone-overlay) > div:first-of-type p {
    display: none;
  }
  #chat-layout {
    padding-top: 0.4rem !important;
    gap: 0.4rem !important;
  }
  /* Превращаем панель контактов на телефоне в компактную однорядную ленту (экономим ~110px высоты экрана!) */
  #chat-sidebar {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 0.4rem !important;
    padding: 0.35rem 0.45rem !important;
    max-height: 3.4rem !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  #chat-sidebar::-webkit-scrollbar {
    display: none;
  }
  #chat-sidebar > div:first-child,
  #chat-sidebar > span {
    display: none !important;
  }
  #chat-btn-global {
    width: auto !important;
    flex-shrink: 0 !important;
    margin-bottom: 0 !important;
    padding: 0.45rem 0.7rem !important;
    white-space: nowrap !important;
  }
  #chat-contacts-list {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 0.4rem !important;
    overflow: visible !important;
    padding-right: 0.25rem !important;
    flex: 1 0 auto !important;
  }
  #chat-contacts-list > button {
    width: auto !important;
    min-width: 7.5rem !important;
    max-width: 11rem !important;
    padding: 0.35rem 0.6rem !important;
    flex-shrink: 0 !important;
  }
  /* Компактная шапка активного диалога и панель мьюта для учителя */
  #chat-conversation > div:first-child {
    padding: 0.45rem 0.65rem !important;
    gap: 0.35rem !important;
  }
  #chat-teacher-mute-bar {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 0.35rem !important;
    padding-top: 0.25rem;
    border-top: 1px solid rgba(41, 26, 79, 0.6);
  }
  #chat-mute-seconds-input {
    width: 4.75rem !important;
    padding: 0.2rem 0.4rem !important;
  }
  #chat-emoji-picker {
    left: 0.5rem !important;
    right: 0.5rem !important;
    max-width: calc(100vw - 1rem) !important;
  }
  #chat-send-btn span:first-child {
    display: none;
  }
  #chat-send-btn {
    padding-inline: 0.85rem !important;
  }

  /* --- Оптимизация Кабинета Учителя и Конструкторов Заданий --- */
  #tt-pane-quiz > div,
  #tt-pane-typing > div,
  #tt-pane-articles > div,
  #tt-pane-routes > div,
  #tt-pane-coding > div {
    padding: 1rem !important;
    border-radius: 1.15rem !important;
  }
  .assignee-picker-root > div[id$="-dropdown"] {
    min-width: 0 !important;
    width: min(290px, calc(100vw - 2.5rem)) !important;
    max-width: calc(100vw - 2.5rem) !important;
    left: 0 !important;
  }
  /* Вкладки кабинета учителя и ученика: плавный свайп без переноса на 3 этажа */
  #teacher-view > div:first-child > div:last-child,
  #student-view > div:first-child > div:last-child {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 0.25rem;
    max-width: 100%;
  }
  #teacher-view > div:first-child > div:last-child::-webkit-scrollbar,
  #student-view > div:first-child > div:last-child::-webkit-scrollbar {
    display: none;
  }
  #teacher-view [id^="tt-tab-"],
  #student-view [id^="st-tab-"] {
    flex: 0 0 auto !important;
    white-space: nowrap !important;
  }

  /* --- Оптимизация Тренажёра Печати, Квизов и Маршрутов на телефоне --- */
  #typing-runner-modal,
  #quiz-runner-modal,
  #route-runner-modal,
  #route-review-modal,
  #article-modal {
    padding: 0.35rem !important;
  }
  #typing-runner-modal > div,
  #quiz-runner-modal > div,
  #route-runner-modal > div,
  #route-review-modal > div,
  #article-modal > div {
    max-height: 96dvh !important;
    border-radius: 1.15rem !important;
    padding: 0.85rem !important;
  }
  #typing-code-body {
    padding: 0.75rem !important;
  }
  #keyboard-map-render {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    padding: 0.5rem !important;
  }
  #keyboard-map-render .kbd-board-canvas {
    min-width: 520px;
  }
}

/* ==========================================================================
   ИДЕАЛЬНОЕ ЦЕНТРИРОВАНИЕ НА ПК И МОБИЛЬНАЯ АДАПТАЦИЯ (v108)
   ========================================================================== */

html, body {
  max-width: 100vw;
  overflow-x: hidden;
}
.site-content {
  max-width: 100vw;
  overflow-x: hidden;
  width: 100%;
  display: flex;
  flex-direction: column;
}

/* СТРОГОЕ ЦЕНТРИРОВАНИЕ КОНТЕНТА НА ПК (1152px / max-w-6xl) */
.site-content > main,
main.max-w-6xl {
  max-width: 72rem !important; /* 1152px */
  width: 100% !important;
  margin-left: auto !important;
  margin-right: auto !important;
  box-sizing: border-box !important;
  padding-left: 1rem !important;
  padding-right: 1rem !important;
}

.site-header-inner,
header .site-header-inner,
header > .max-w-6xl {
  max-width: 72rem !important; /* 1152px */
  width: 100% !important;
  margin-left: auto !important;
  margin-right: auto !important;
  box-sizing: border-box !important;
}

/* --- Десктопная шапка (от 900px): красивое выравнивание по центру и справа --- */
@media (min-width: 900px) {
  .site-header-inner {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
  }
  #header-brand {
    order: 1 !important;
    flex: 0 0 auto !important;
  }
  #u-student-center {
    order: 2 !important;
    flex: 1 1 auto !important;
    max-width: 280px !important;
    margin: 0 auto !important;
  }
  #u-stats {
    order: 3 !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 0.5rem !important;
    margin-left: auto !important;
    margin-right: 0.6rem !important;
    width: auto !important;
  }
  #u-stats.hidden {
    display: none !important;
  }
  #header-actions-wrapper {
    order: 4 !important;
    flex: 0 0 auto !important;
    margin-left: 0 !important;
  }
  #header-actions {
    display: flex !important;
    align-items: center !important;
    gap: 0.4rem !important;
    flex-wrap: nowrap !important;
  }
}

/* --- Мобильная шапка (до 899px): кнопки действий ВСЕГДА в 1-й строке! --- */
@media (max-width: 899px) {
  .site-header-inner {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
    gap: 0.25rem 0.5rem !important;
  }
  #header-brand {
    order: 1 !important;
    flex: 0 0 auto !important;
  }
  #header-brand svg {
    width: 2rem !important;
    height: 2rem !important;
  }
  #header-actions-wrapper {
    order: 2 !important;
    margin-left: auto !important;
    flex: 0 0 auto !important;
  }
  #header-actions {
    display: flex !important;
    align-items: center !important;
    gap: 0.25rem !important;
    flex-wrap: nowrap !important;
  }
  #header-actions > button {
    min-height: 2.15rem !important;
    padding-inline: 0.45rem !important;
    font-size: 11px !important;
  }

  /* Вторая строка: Статистика Учителя или Профиль Ученика */
  #u-student-center {
    order: 3 !important;
    width: 100% !important;
    margin-top: 0.35rem !important;
    padding-top: 0.35rem !important;
    border-top: 1px solid rgba(41, 26, 79, 0.6) !important;
  }
  #u-student-center.hidden {
    display: none !important;
  }
  #u-stats {
    order: 3 !important;
    width: 100% !important;
    margin-top: 0.35rem !important;
    padding-top: 0.35rem !important;
    border-top: 1px solid rgba(41, 26, 79, 0.6) !important;
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 0.35rem !important;
  }
  #u-stats.hidden {
    display: none !important;
  }
  #u-stats > div {
    padding: 0.25rem 0.2rem !important;
    min-width: 0 !important;
    text-align: center !important;
    border-radius: 0.65rem !important;
  }
  #u-stats > div span:first-child {
    font-size: 8px !important;
    line-height: 1 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    max-width: 100% !important;
  }
  #u-stats > div span:last-child {
    font-size: 11px !important;
    line-height: 1.2 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  /* Панель вкладок Учителя: свайп в один ряд вместо 4 этажей */
  #teacher-tabs-container {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    gap: 0.4rem !important;
    padding-bottom: 0.4rem !important;
    margin-bottom: 0.5rem !important;
    scrollbar-width: none;
  }
  #teacher-tabs-container::-webkit-scrollbar {
    display: none;
  }
  #teacher-tabs-container > button {
    flex: 0 0 auto !important;
    width: auto !important;
    padding: 0.45rem 0.75rem !important;
    font-size: 11px !important;
    min-height: 2.2rem !important;
    white-space: nowrap !important;
  }

  /* Формы создания заданий */
  .teacher-form-actions-bar {
    gap: 0.5rem !important;
  }
  .teacher-form-actions-bar > button {
    flex: 1 1 calc(50% - 0.5rem) !important;
    min-height: 2.3rem !important;
    text-align: center !important;
    justify-content: center !important;
  }
  #code-task-assigned-picker {
    width: 100% !important;
    min-width: 0 !important;
  }
  #code-task-assigned-btn {
    width: 100% !important;
  }

  /* Таблицы с горизонтальным скроллом */
  .overflow-x-auto {
    -webkit-overflow-scrolling: touch;
    max-width: 100% !important;
    overflow-x: auto !important;
  }
}

