/* Фирменный стиль ITclub: чёрный + голубой #3fd6fe + оранжевый #ff8200.
   Страницы материалов повторяют оформление docx-методичек школы. */
:root {
  --black: #111111;
  --cyan: #3fd6fe;
  --orange: #ff8200;
  --blue: #1f5bff;
  --ice: #dbf6f9;
  --bg: #f4fbfd;
  --panel: #ffffff;
  --line: #d8e6ec;
  --text: #2b2b2b;
  --muted: #6b7a86;
  --doc-accent: #0091cf;
  --code-bg: #f5f5f5;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(17, 60, 80, 0.08);
  --font-ui: "Nunito", -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-doc: Calibri, "Segoe UI", -apple-system, sans-serif;
  --font-code: Consolas, "JetBrains Mono", monospace;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.6 var(--font-ui);
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.error { color: #d63030; }

/* --- шапка (чёрная, фирменная) --- */
.topbar {
  display: flex; align-items: center; gap: 22px;
  padding: 10px 22px; background: var(--black);
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}
.brand { display: flex; align-items: center; gap: 32px; color: #fff; font-weight: 800; font-size: 17px; line-height: 1; }
/* «club» внутри картинки логотипа сидит ниже центра круга — приподнимаем,
   чтобы слово club стояло на одной линии с «Курсы» */
.brand img { position: relative; top: -2.5px; }
.brand span { position: relative; top: -1px; }  /* оптическое выравнивание по логотипам */
.brand:hover { text-decoration: none; }
.brand img { height: 26px; width: auto; display: block; }
.topnav { display: flex; align-items: center; }
.topnav a {
  margin-right: 6px; padding: 6px 10px; border-radius: 8px; line-height: 1;
  color: #cfd8de; font-weight: 600; font-size: 15px;
}
.topnav a:hover { color: #fff; text-decoration: none; }
.topnav a.active { color: var(--cyan); }
.topnav a .course-logo { height: 26px; width: auto; display: block; }
.topnav a.active .course-logo { filter: drop-shadow(0 0 6px rgba(63, 214, 254, 0.7)); }
.searchbox { position: relative; margin-left: auto; }
#search-input {
  width: 260px; padding: 7px 12px;
  background: #22282e; color: #fff;
  border: 1px solid #3a434c; border-radius: 8px;
  font-family: var(--font-ui);
}
#search-input::placeholder { color: #8a97a1; }
#search-input:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(63, 214, 254, 0.25); }
.search-results {
  position: absolute; top: 110%; right: 0; width: 380px; max-height: 60vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18); z-index: 200;
}
.search-results a { display: block; padding: 8px 12px; color: var(--text); border-bottom: 1px solid var(--line); }
.search-results a:hover { background: var(--ice); text-decoration: none; }
.search-results .snip { display: block; font-size: 12px; color: var(--muted); }
.chat-link {
  white-space: nowrap; padding: 6px 14px; border-radius: 999px;
  background: var(--orange); color: #fff !important; font-weight: 700;
}
.chat-link:hover { background: #e67400; text-decoration: none; }
.userbox { display: flex; gap: 12px; align-items: center; white-space: nowrap; color: #cfd8de; font-size: 14px; }
.userbox a { color: var(--cyan); }

/* --- раскладка курса --- */
.layout { display: flex; align-items: flex-start; max-width: 1280px; margin: 0 auto; padding: 22px; gap: 24px; }
.sidebar {
  flex: 0 0 280px; position: sticky; top: 70px; max-height: calc(100vh - 90px); overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.tree h3 {
  margin: 16px 0 6px; font-size: 12px; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--orange); font-weight: 800;
}
.tree h3:first-child { margin-top: 4px; }
.tree ul { list-style: none; margin: 0; padding: 0; }
.tree li { margin: 2px 0; }
.tree a { display: block; padding: 4px 10px; border-radius: 8px; color: var(--text); font-size: 14px; }
.tree a:hover { background: var(--bg); text-decoration: none; }
.tree a.current { background: var(--ice); color: #005f87; font-weight: 700; }
.tree a b { color: var(--doc-accent); font-weight: 800; }
.tree-index { font-weight: 800; }
/* вики-ссылки на уроки/концепции в тексте — голубые, как заголовки методичек */
.content a.wlink { color: var(--doc-accent); font-weight: 700; }

/* --- контент: оформление как в docx-методичках --- */
.content {
  position: relative;
  flex: 1; min-width: 0; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 28px 36px; box-shadow: var(--shadow);
  font-family: var(--font-doc); font-size: 16px; color: #2b2b2b;
}
.content-logo {
  position: absolute; top: 20px; right: 28px;
  width: 92px; height: auto; opacity: 0.9;
}
.content h1, .content h2, .content h3 { font-family: var(--font-doc); line-height: 1.3; }
.content h1 {
  font-size: 26px; color: #0076a8;
  border-bottom: 3px solid var(--orange); padding-bottom: 8px;
}
.content h2 { font-size: 21px; margin-top: 28px; color: var(--doc-accent); }
.content h3 { font-size: 17px; color: var(--doc-accent); }
.content img { max-width: 100%; }
.content pre {
  background: var(--code-bg); border: 1px solid #e3e3e3;
  padding: 14px 16px; border-radius: 8px; overflow-x: auto;
}
.content code { font-family: var(--font-code); font-size: 13.5px; }
.content :not(pre) > code { background: var(--code-bg); padding: 2px 5px; border-radius: 4px; }
/* подсветка кода в тёплых тонах методичек (вместо темы github) */
.hljs { color: #2b2b2b; background: var(--code-bg); }
.hljs-keyword, .hljs-selector-tag, .hljs-built_in { color: #cc7832; }
.hljs-string, .hljs-attr { color: #6a8759; }
.hljs-number, .hljs-literal, .hljs-title, .hljs-name { color: #6897bb; }
.hljs-comment, .hljs-quote { color: #7a7ab8; font-style: italic; }
.content table { border-collapse: collapse; margin: 12px 0; }
.content th, .content td { border: 1px solid var(--line); padding: 7px 12px; }
.content th { background: var(--ice); }
.content blockquote {
  margin: 12px 0; padding: 8px 16px;
  border-left: 4px solid var(--cyan); background: var(--bg); border-radius: 0 8px 8px 0;
}

/* --- view-only (02_Для_преподавателя и wiki-страницы) --- */
.view-only .content.protected { user-select: none; -webkit-user-select: none; }
@media print {
  .view-only .content.protected { display: none !important; }
  .view-only::after { content: "Печать этой страницы отключена."; }
  .topbar, .sidebar, .watermark { display: none !important; }
}

/* --- водяной знак: аккуратная плашка в правом нижнем углу --- */
.watermark {
  position: fixed; right: 14px; bottom: 12px; z-index: 900;
  pointer-events: none;
  font-size: 12.5px; font-weight: 600; color: rgba(20, 30, 45, 0.85);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(20, 30, 45, 0.25);
  border-radius: 999px; padding: 4px 13px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.12);
  white-space: nowrap;
}

/* --- список курсов --- */
.course-list { list-style: none; padding: 0; display: flex; gap: 16px; flex-wrap: wrap; }
.course-list a {
  display: block; padding: 0; min-width: 200px; overflow: hidden;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); color: var(--text); font-weight: 800; font-size: 18px;
  text-align: center;
}
.course-list .course-card-img { display: block; width: 260px; height: auto; }
.course-list a:hover { border-color: var(--cyan); text-decoration: none; box-shadow: 0 4px 16px rgba(63, 214, 254, 0.25); }

/* --- логин --- */
.login-page { display: grid; place-items: center; min-height: 100vh; background: var(--ice); }
.login-form {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 36px; width: 360px; display: flex; flex-direction: column; gap: 14px;
}
.login-form img { width: 150px; margin: 0 auto 6px; display: block; }
.login-form h1 { margin: 0; text-align: center; font-size: 22px; }
.login-form .muted { text-align: center; margin: 0; }
.login-form label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; font-weight: 600; }
.login-form input {
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px;
  font-family: var(--font-ui); font-size: 15px;
}
.login-form input:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(63, 214, 254, 0.25); }

button {
  padding: 9px 16px; border: 0; border-radius: 8px;
  background: var(--blue); color: #fff; cursor: pointer;
  font-family: var(--font-ui); font-weight: 700; font-size: 14px;
}
button:hover { filter: brightness(1.12); }

/* --- админка --- */
.admin { display: block; }
.admin-table {
  border-collapse: collapse; width: 100%; background: var(--panel);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}
.admin-table th, .admin-table td { border: 1px solid var(--line); padding: 9px 12px; text-align: left; }
.admin-table th { background: var(--black); color: #fff; border-color: #333; }
.admin-table form { display: flex; gap: 6px; }
.admin-table input { padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; font-family: var(--font-ui); }
.admin-add { display: flex; gap: 8px; margin-top: 8px; }
.admin-add input {
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px;
  font-family: var(--font-ui);
}

/* --- чат --- */
.chat-wrap { flex: 1; max-width: 820px; margin: 0 auto; width: 100%; }
.chat-log { display: flex; flex-direction: column; gap: 12px; margin: 16px 0; }
.chat-msg { padding: 12px 16px; border-radius: 12px; white-space: pre-wrap; }
.chat-msg.user { background: var(--ice); align-self: flex-end; max-width: 80%; }
.chat-msg.bot {
  background: var(--panel); border: 1px solid var(--line);
  box-shadow: var(--shadow); max-width: 90%;
}
.chat-msg .pages { display: block; margin-top: 8px; font-size: 12px; color: var(--muted); white-space: normal; }
.chat-form { display: flex; gap: 8px; }
.chat-form input {
  flex: 1; padding: 11px 14px; border: 1px solid var(--line); border-radius: 10px;
  font-family: var(--font-ui); font-size: 15px;
}
.chat-form input:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(63, 214, 254, 0.25); }
.chat-form button { background: var(--orange); }
.chat-form button:hover { background: #e67400; filter: none; }

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { position: static; max-height: none; flex: none; width: 100%; }
  #search-input { width: 160px; }
}
