
:root { --bg:#0f1115; --panel:#171a21; --text:#e6e6e6; --muted:#9aa4b2; --accent:#ffd633; }
*{box-sizing:border-box} body{margin:0;font-family:Inter,Segoe UI,Roboto,Arial,sans-serif;background:var(--bg);color:var(--text)}
.container{max-width:1100px;margin:0 auto;padding:0 16px}
header{padding:24px 0;border-bottom:1px solid #22262f;background:linear-gradient(180deg,#1b1f2a 0%,#151922 100%)}
.header-content{display:flex;align-items:center;gap:16px}
.menu-btn{background:var(--accent);color:#111;border:none;border-radius:8px;padding:10px 16px;font-size:20px;cursor:pointer;font-weight:700;box-shadow:0 4px 12px rgba(255,214,51,.3);transition:transform 0.2s}
.menu-btn:hover{transform:scale(1.05)}
.subtitle{color:var(--muted);margin-left:auto}
.auth-buttons{display:flex;align-items:center;gap:12px;margin-left:auto}
.user-email{color:var(--muted);font-size:14px;margin-right:8px}
.auth-btn{background:#2a2f3a;color:var(--text);border:1px solid #3a3f4a;border-radius:8px;padding:8px 16px;font-size:14px;cursor:pointer;font-weight:600;transition:all 0.2s}
.auth-btn:hover{background:#3a3f4a;border-color:var(--accent);color:var(--accent)}
.logout-btn{background:rgba(255,82,82,0.1);border-color:rgba(255,82,82,0.3);color:#ff5252}
.logout-btn:hover{background:rgba(255,82,82,0.2);border-color:#ff5252}
.sidebar{position:fixed;left:-350px;top:0;width:350px;height:100vh;background:var(--panel);border-right:1px solid #22262f;z-index:1000;transition:left 0.3s ease;box-shadow:4px 0 20px rgba(0,0,0,.5);overflow-y:auto}
.sidebar.open{left:0}
.sidebar-header{display:flex;justify-content:space-between;align-items:center;padding:20px;border-bottom:1px solid #22262f;background:linear-gradient(180deg,#1b1f2a 0%,#151922 100%)}
.sidebar-header h2{margin:0;font-size:20px;color:var(--text)}
.close-btn{background:none;border:none;color:var(--text);font-size:24px;cursor:pointer;padding:4px 12px;border-radius:6px;transition:background 0.2s}
.close-btn:hover{background:#22262f}
.sidebar-content{padding:16px}
.main-chapter-section{margin-bottom:20px}
.main-chapter-title{font-size:18px;font-weight:700;color:var(--accent);padding:14px 16px;background:linear-gradient(135deg,#2a2f3a 0%,#22262f 100%);border-radius:10px;margin-bottom:10px;cursor:pointer;display:flex;justify-content:space-between;align-items:center;transition:all 0.2s;border:1px solid rgba(255,214,51,0.2)}
.main-chapter-title:hover{background:linear-gradient(135deg,#323844 0%,#2a2f3a 100%);border-color:rgba(255,214,51,0.4)}
.main-chapter-content{padding-left:12px;transition:opacity 0.2s ease, max-height 0.3s ease;overflow:hidden;max-height:5000px;opacity:1}
.main-chapter-content[style*="display: none"]{max-height:0;opacity:0}
.subsection-section{margin-bottom:12px}
.subsection-title{font-size:15px;font-weight:600;color:#b8c0cc;padding:10px 14px;background:#22262f;border-radius:8px;margin-bottom:6px;cursor:pointer;display:flex;justify-content:space-between;align-items:center;transition:background 0.2s;border-left:3px solid #2a2f3a;position:relative}
.subsection-title:hover{background:#2a2f3a}
.subsection-title[style*="border-left: 3px solid var(--accent)"]{border-left-color:var(--accent)!important}
.subsection-tasks{padding-left:12px;transition:opacity 0.2s ease, max-height 0.3s ease;overflow:hidden;max-height:2000px;opacity:1}
.subsection-tasks[style*="display: none"]{max-height:0;opacity:0}
.chapter-section{margin-bottom:24px}
.chapter-title{font-size:16px;font-weight:700;color:var(--accent);padding:12px 16px;background:#22262f;border-radius:8px;margin-bottom:8px;cursor:pointer;display:flex;justify-content:space-between;align-items:center;transition:background 0.2s}
.chapter-title:hover{background:#2a2f3a}
.chapter-toggle{font-size:14px;transition:transform 0.2s}
.chapter-title.collapsed .chapter-toggle,.main-chapter-title.collapsed .chapter-toggle,.subsection-title.collapsed .chapter-toggle{transform:rotate(-90deg)}
.chapter-tasks{padding-left:8px;transition:opacity 0.2s ease, max-height 0.3s ease;overflow:hidden;max-height:2000px;opacity:1}
.chapter-tasks[style*="display: none"]{max-height:0;opacity:0}
.task-item{padding:10px 16px;margin:4px 0;background:#22262f;border-radius:8px;cursor:pointer;transition:all 0.2s;border-left:3px solid transparent}
.task-item:hover{background:#2a2f3a;border-left-color:var(--accent);transform:translateX(4px)}
.task-item.active{background:#2a3542;border-left-color:var(--accent);box-shadow:0 2px 8px rgba(255,214,51,.2)}
.task-item-title{font-weight:600;color:var(--text);margin-bottom:4px}
.task-item-id{font-size:12px;color:var(--muted)}
.sidebar-overlay{position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,0.5);z-index:999;opacity:0;visibility:hidden;transition:opacity 0.3s, visibility 0.3s}
.sidebar-overlay.visible{opacity:1;visibility:visible}
.grid{display:grid;grid-template-columns:1fr 2fr 1fr;gap:16px;margin:20px 0}
.panel{background:var(--panel);border:1px solid #22262f;border-radius:16px;padding:16px;box-shadow:0 10px 30px rgba(0,0,0,.35);min-height:200px}
.actions{display:flex;gap:12px;align-items:center;margin:10px 0}
button#run{background:var(--accent);color:#111;border:none;border-radius:12px;padding:10px 16px;font-weight:700;cursor:pointer;box-shadow:0 6px 16px rgba(255,214,51,.3);transition:all 0.2s}
button#run:hover:not(:disabled){transform:translateY(-2px);box-shadow:0 8px 20px rgba(255,214,51,.4)}
button#run:disabled{background:#444;color:#888;cursor:not-allowed;box-shadow:none;opacity:0.7}
#status{color:var(--muted)}
.CodeMirror{
  height:300px;
  min-height:200px;
  max-height:600px;
  min-width:400px;
  max-width:100%;
  border:1px solid #2a2f3a;
  border-radius:8px;
  font-family:'Courier New',Courier,monospace;
  font-size:14px;
  line-height:1.6;
}
.CodeMirror-scroll{
  min-height:200px;
  max-height:600px;
}
.CodeMirror-wrap pre{
  word-wrap:break-word;
  white-space:pre-wrap;
  word-break:normal;
}
#result{margin-top:8px;border:1px solid #2a2f3a;border-radius:12px;overflow-x:auto}
table{width:100%;border-collapse:collapse;font-size:14px}
th,td{border-bottom:1px solid #242a33;padding:8px 10px;text-align:left}
th{background:#10131a;color:#b8c0cc}
tr:hover td{background:#0d1016}
.hints{color:#ffd185;margin-bottom:6px}
footer{padding:18px 0;color:var(--muted);border-top:1px solid #22262f;background:var(--panel);transition:background-color 0.3s ease}
footer .container{min-height:100px}
footer table{width:100%;border-collapse:collapse;font-size:14px;margin-top:10px}
footer th,footer td{border-bottom:1px solid #242a33;padding:8px 10px;text-align:left}
footer th{background:#10131a;color:#b8c0cc}
footer tr:hover td{background:#0d1016}

/* Цветовые индикаторы для результата */
#resultFooter.result-success {
  background: rgba(76, 175, 80, 0.1);
  border-top-color: rgba(76, 175, 80, 0.3);
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

#resultFooter.result-warning {
  background: rgba(255, 152, 0, 0.1);
  border-top-color: rgba(255, 152, 0, 0.3);
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

#resultFooter.result-error {
  background: rgba(244, 67, 54, 0.1);
  border-top-color: rgba(244, 67, 54, 0.3);
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

#resultFooter.result-info {
  background: rgba(33, 150, 243, 0.1);
  border-top-color: rgba(33, 150, 243, 0.3);
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* Анимации */
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.panel {
  animation: fadeIn 0.3s ease;
}

/* ========== МОБИЛЬНАЯ АДАПТАЦИЯ ========== */
@media (max-width: 768px) {
  body {
    font-size: 16px;
  }

  .container {
    padding: 0 12px;
  }

  header {
    padding: 16px 0;
  }

  .header-content {
    flex-wrap: wrap;
    gap: 12px;
  }

  .header-content h1 {
    font-size: 18px;
    flex: 1;
    min-width: 0;
  }

  .subtitle {
    display: none; /* Скрываем на мобильных */
  }

  .auth-buttons {
    margin-left: 0;
    width: 100%;
    justify-content: flex-end;
    order: 3;
  }

  .auth-btn {
    padding: 10px 16px;
    font-size: 14px;
    min-height: 48px;
  }

  .menu-btn {
    min-height: 48px;
    min-width: 48px;
    padding: 12px;
  }

  /* Сайдбар на мобильных занимает всю ширину */
  .sidebar {
    width: 100%;
    left: -100%;
  }

  /* Вертикальная раскладка панелей */
  .grid {
    grid-template-columns: 1fr;
    gap: 12px;
    margin: 12px 0;
  }

  .panel {
    padding: 12px;
    min-height: auto;
  }

  .panel h2 {
    font-size: 18px;
    margin-bottom: 12px;
  }

  /* Редактор на всю ширину */
  .CodeMirror {
    width: 100%;
    min-width: 100%;
    max-width: 100%;
    height: 250px;
    min-height: 200px;
    max-height: 400px;
    font-size: 16px; /* Увеличиваем для удобства на мобильных */
  }

  .CodeMirror-scroll {
    min-height: 200px;
    max-height: 400px;
  }

  /* Кнопки на всю ширину и больше */
  .actions {
    flex-direction: column;
    gap: 8px;
  }

  button, .btn {
    width: 100%;
    min-height: 48px;
    padding: 12px 16px;
    font-size: 16px;
    margin-top: 8px;
    border-radius: 12px;
  }

  button#run {
    width: 100%;
    min-height: 48px;
    padding: 14px 20px;
    font-size: 16px;
  }

  /* Таблицы с горизонтальной прокруткой */
  #result, #resultFooter {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 600px; /* Минимальная ширина для таблиц */
    font-size: 14px;
  }

  footer table {
    min-width: 600px;
  }

  /* Списки задач адаптируем */
  .task-item {
    padding: 12px 16px;
    min-height: 48px;
    display: flex;
    align-items: center;
  }

  .task-item-title {
    font-size: 15px;
  }

  /* Улучшаем отступы для тач-управления */
  .main-chapter-title,
  .subsection-title {
    min-height: 48px;
    padding: 14px 16px;
  }

  /* Скрываем некоторые элементы на мобильных */
  .chapter-toggle {
    font-size: 16px;
  }
}

/* Дополнительные стили для очень маленьких экранов */
@media (max-width: 480px) {
  .header-content h1 {
    font-size: 16px;
  }

  .panel {
    padding: 10px;
  }

  .CodeMirror {
    font-size: 14px;
  }

  button, .btn {
    font-size: 15px;
    padding: 12px 14px;
  }
}

/* Улучшение контрастности текста */
.CodeMirror {
  color: #e6e6e6;
  background: #1a1d24;
}

.CodeMirror-cursor {
  border-left-color: #ffd633;
}

.CodeMirror-selected {
  background: rgba(255, 214, 51, 0.2);
}

/* Улучшение контрастности в таблицах результатов */
table {
  color: #e6e6e6;
}

th {
  color: #b8c0cc;
  font-weight: 600;
}

td {
  color: #e6e6e6;
}

/* Tooltip стили */
button[title] {
  position: relative;
}

button[title]:hover::after {
  content: attr(title);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 10px;
  background: #1a1d24;
  color: #e6e6e6;
  border: 1px solid #3a3f4a;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 1000;
  margin-bottom: 5px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  pointer-events: none;
  animation: fadeIn 0.2s ease;
}

@media (max-width:980px){.grid{grid-template-columns:1fr};.sidebar{width:300px;left:-300px}.subtitle{display:none}}
