:root {
  --bg: #f7f8fb;
  --bg-alt: #eef0f7;
  --card: #ffffff;
  --text: #1d2333;
  --muted: #5c6478;
  --line: #e3e6ef;
  --brand: #3b5bdb;
  --brand-dark: #2f49b0;
  --brand-soft: #e8ecfb;
  --accent: #f08c00;
  --phys: #0ca678;
  --phys-soft: #e6fcf5;
  --ok: #2f9e44;
  --bad: #e03131;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(29, 35, 51, 0.08);
  --container: 1120px;
}

[data-theme="dark"] {
  --bg: #12141c;
  --bg-alt: #181b26;
  --card: #1d2130;
  --text: #eef0f7;
  --muted: #9aa3b8;
  --line: #2b3040;
  --brand: #7d9bff;
  --brand-dark: #9fb4ff;
  --brand-soft: #232a42;
  --phys: #63e6be;
  --phys-soft: #0b2b23;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background 0.25s, color 0.25s;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 20px;
}

img { max-width: 100%; }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 68px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
}
.brand:hover { text-decoration: none; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--brand);
  color: #fff;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1;
}

.brand-name { display: block; font-weight: 700; font-size: 17px; line-height: 1.2; }
.brand-sub { display: block; font-size: 12px; color: var(--muted); line-height: 1.2; }

/* ---------- Лента арабских математиков ---------- */
.ribbon {
  background: linear-gradient(135deg, #0b3d2e, #14604a 45%, #0b3d2e);
  border-bottom: 3px solid #d4a017;
  overflow: hidden;
}
.ribbon-inner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-top: 8px;
  padding-bottom: 8px;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}
.ribbon-inner::-webkit-scrollbar { display: none; }
.ribbon-title {
  color: #f5d67b;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.03em;
  flex-shrink: 0;
}
.ribbon-chip {
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(212, 160, 23, 0.5);
  border-radius: 999px;
  color: #f0ead6;
  font-size: 12px;
  padding: 3px 10px;
  flex-shrink: 0;
}
.ribbon-chip b { color: #f5d67b; }

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
}
.nav-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text);
  margin: 4px 0;
  transition: transform 0.2s, opacity 0.2s;
}

.main-nav { display: flex; align-items: center; gap: 4px; }

.nav-ico { display: none; }

.main-nav a {
  color: var(--text);
  padding: 8px 12px;
  border-radius: 10px;
  font-weight: 500;
  font-size: 15px;
}
.main-nav a:hover { background: var(--brand-soft); text-decoration: none; }
.main-nav a.active {
  background: var(--brand);
  color: #fff;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 16px;
  margin-left: 4px;
}

/* ---------- Hero ---------- */
.hero {
  background: linear-gradient(135deg, var(--brand-soft), var(--bg-alt));
  padding: 72px 0 64px;
  border-bottom: 1px solid var(--line);
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 48px;
  align-items: center;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 13px;
  font-weight: 700;
  color: var(--brand);
  margin: 0 0 12px;
}

.hero h1 {
  font-size: clamp(30px, 4.5vw, 46px);
  line-height: 1.15;
  margin: 0 0 16px;
}

.accent { color: var(--accent); }

.hero-lead { font-size: 18px; color: var(--muted); margin: 0 0 28px; max-width: 34em; }

.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }

.hero-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 36px 28px;
  text-align: center;
}

.hero-side {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.photo-frame {
  position: relative;
  width: 100%;
  max-width: 340px;
  aspect-ratio: 4 / 5;
  margin: 0 auto;
  border-radius: 18px;
  overflow: hidden;
  border: 4px solid var(--card);
  outline: 1px solid var(--line);
  box-shadow: var(--shadow);
  background: var(--bg-alt);
}
.photo-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.photo-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--muted);
  font-weight: 600;
  text-align: center;
  padding: 16px;
}
.photo-ico { font-size: 44px; }
.photo-hint { font-size: 12px; font-weight: 400; opacity: 0.8; }

.big-formula {
  font-size: clamp(34px, 5vw, 54px);
  font-weight: 600;
  color: var(--brand);
  line-height: 1.2;
}

.formula-note { color: var(--muted); margin: 16px 0 0; font-style: italic; }
.formula-inline { color: var(--phys); font-weight: 600; white-space: nowrap; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  padding: 12px 22px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 15px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }

.btn-primary {
  background: var(--brand);
  color: #fff;
}
.btn-primary:hover { background: var(--brand-dark); box-shadow: 0 4px 16px rgba(59, 91, 219, 0.35); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-ghost {
  background: var(--card);
  color: var(--text);
  border-color: var(--line);
}
.btn-ghost:hover { border-color: var(--brand); }

.btn-light { background: #fff; color: var(--brand-dark); }
.btn-light:hover { background: #f2f4ff; }

.btn-small { padding: 8px 14px; font-size: 14px; border-radius: 9px; }

.disabled-placeholder {
  background: var(--bg-alt);
  color: var(--muted);
  border-color: var(--line);
  cursor: not-allowed;
}

/* ---------- Sections ---------- */
.section { padding: 56px 0; }
.section-alt { background: var(--bg-alt); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }

.section-title { font-size: 28px; margin: 0 0 24px; }

.page-head { padding: 48px 0 8px; }
.page-head h1 { font-size: clamp(28px, 4vw, 40px); margin: 0 0 10px; }
.page-head p:not(.eyebrow) { color: var(--muted); font-size: 17px; margin: 0 0 0; max-width: 44em; }

/* ---------- Cards ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}
.cards-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px 22px;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
  display: block;
  color: var(--text);
}
.card:hover { transform: translateY(-3px); box-shadow: 0 12px 30px rgba(29, 35, 51, 0.12); text-decoration: none; }
.card-accent { border-top: 4px solid var(--brand); }

.card-ico { font-size: 30px; display: block; margin-bottom: 10px; }
.card h3 { margin: 0 0 8px; font-size: 19px; }
.card p { margin: 0; color: var(--muted); font-size: 15px; }
.card-time { color: var(--brand) !important; font-weight: 600; margin-bottom: 8px !important; }

/* ---------- Approach / stats ---------- */
.approach-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
}

.approach-item { position: relative; padding-top: 40px; }
.approach-item .num {
  position: absolute;
  top: 0;
  left: 0;
  font-size: 40px;
  font-weight: 800;
  color: var(--brand-soft);
  line-height: 1;
}
.approach-item h3 { margin: 0 0 8px; font-size: 18px; }
.approach-item p { margin: 0; color: var(--muted); }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 20px;
}

.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-num { display: block; font-size: 38px; font-weight: 800; color: var(--brand); line-height: 1.1; }
.stat-label { color: var(--muted); font-size: 14px; }

/* ---------- CTA ---------- */
.section-cta { padding-bottom: 64px; }
.cta-box {
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff;
  border-radius: 20px;
  padding: 48px 40px;
  text-align: center;
}
.cta-box h2 { margin: 0 0 10px; font-size: 28px; }
.cta-box p { margin: 0 0 22px; opacity: 0.9; }

/* ---------- Footer ---------- */
.site-footer {
  background: var(--card);
  border-top: 1px solid var(--line);
  padding: 36px 0 20px;
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 28px;
  margin-bottom: 24px;
}

.footer-brand { font-weight: 700; margin: 0 0 4px; }

.footer-bottom {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  border-top: 1px solid var(--line);
  padding-top: 16px;
  font-size: 14px;
}

.muted { color: var(--muted); }

/* ---------- Materials page ---------- */
.filters {
  display: grid;
  grid-template-columns: 180px 180px 1fr;
  gap: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 26px;
}

.filter-group { display: flex; flex-direction: column; gap: 6px; }
.filter-label { font-size: 13px; font-weight: 600; color: var(--muted); }

.filters select,
.filters input {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}

.mat-list { display: flex; flex-direction: column; gap: 16px; }

.mat-item {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 20px;
  align-items: start;
}
.mat-item h3 { margin: 0 0 6px; font-size: 19px; grid-column: 1 / -1; }
.mat-item p { margin: 0 0 10px; color: var(--muted); }
.mat-item[hidden] { display: none; }

.mat-badge {
  grid-column: 1 / -1;
  justify-self: start;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 4px;
}
.mat-item[data-subject="Физика"] .mat-badge {
  background: var(--phys-soft);
  color: var(--phys);
}

.empty-hint { text-align: center; padding: 30px 0; }

/* ---------- Trainers ---------- */
.trainer-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }

.tab {
  padding: 10px 18px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.tab:hover { border-color: var(--brand); }
.tab.is-active { background: var(--brand); border-color: var(--brand); color: #fff; }

.tab-physics { border-color: var(--phys); color: var(--phys); }
.tab-physics:hover { background: var(--phys-soft); }
.tab-physics.is-active { background: var(--phys); border-color: var(--phys); color: #fff; }

.tab-custom { border-style: dashed; border-color: var(--accent); color: var(--accent); }
.tab-custom:hover { background: rgba(240, 140, 0, 0.1); }
.tab-custom.is-active { background: var(--accent); border-color: var(--accent); color: #fff; border-style: solid; }

/* ---------- Admin ---------- */
.admin-wrap { max-width: 820px; }

.admin-login { max-width: 380px; }

.admin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.admin-topics { display: flex; flex-direction: column; gap: 10px; }

.admin-topic {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 18px;
  box-shadow: var(--shadow);
}
.admin-topic h3 { margin: 0 0 2px; font-size: 17px; }
.admin-topic p { margin: 0; font-size: 13px; }

.btn-danger { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn-danger:hover { background: #c92a2a; }

.admin-form {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.admin-question {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.aq-head { display: flex; align-items: center; justify-content: space-between; }
.aq-num { font-weight: 700; color: var(--brand); }

.admin-actions { display: flex; gap: 12px; flex-wrap: wrap; }

.trainer-wrap {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
  max-width: 640px;
}

.trainer-head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 18px;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
}

.trainer-question {
  font-size: clamp(26px, 4vw, 40px);
  font-weight: 700;
  text-align: center;
  padding: 18px 0 24px;
  min-height: 80px;
}

.trainer-answers { display: flex; flex-direction: column; gap: 12px; }

.t-input {
  width: 100%;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  font-size: 22px;
  font-weight: 600;
  text-align: center;
  font-family: inherit;
}
.t-input:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
.t-input:disabled { opacity: 0.6; }

.trainer-answers .btn { align-self: flex-end; }

.trainer-hint { margin: 10px 0 0; font-size: 14px; color: var(--muted); }

.t-answer {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  font-size: 17px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.t-answer:hover { border-color: var(--brand); }
.t-answer.is-correct { border-color: var(--ok); background: rgba(47, 158, 68, 0.12); }
.t-answer.is-wrong { border-color: var(--bad); background: rgba(224, 49, 49, 0.1); }
.t-answer:disabled { cursor: default; opacity: 1; }

.answer-letter {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.t-answer.is-correct .answer-letter { background: var(--ok); color: #fff; }
.t-answer.is-wrong .answer-letter { background: var(--bad); color: #fff; }

.trainer-feedback {
  margin-top: 18px;
  padding: 14px 18px;
  border-radius: 12px;
  font-size: 16px;
}
.trainer-feedback.ok { background: rgba(47, 158, 68, 0.12); border: 1px solid var(--ok); }
.trainer-feedback.bad { background: rgba(224, 49, 49, 0.1); border: 1px solid var(--bad); }

.trainer-actions { display: flex; gap: 12px; margin-top: 22px; justify-content: flex-end; }

.trainer-result {
  text-align: center;
  padding: 16px 0;
}
.trainer-result .big { font-size: 52px; font-weight: 800; color: var(--brand); }
.trainer-result .sub { color: var(--muted); }

.trainer-info { margin-top: 18px; }

/* ---------- Posts ---------- */
.posts { display: flex; flex-direction: column; gap: 18px; }

.post {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow);
}
.post h2 { margin: 8px 0 6px; font-size: 22px; }
.post h2 a { color: var(--text); }
.post h2 a:hover { color: var(--brand); }
.post-meta { color: var(--muted); font-size: 14px; margin: 0 0 10px; }
.post p:last-child { margin-bottom: 0; color: var(--muted); }

.post-tag {
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
}

/* ---------- Schedule ---------- */
.schedule-table-wrap { overflow-x: auto; }

.schedule-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.schedule-table th, .schedule-table td {
  padding: 14px 18px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}
.schedule-table thead th { background: var(--brand); color: #fff; font-weight: 600; }
.schedule-table tbody tr:hover { background: var(--bg-alt); }
.schedule-table tbody tr:last-child td { border-bottom: none; }

.note-box {
  background: var(--brand-soft);
  border-left: 4px solid var(--brand);
  border-radius: 10px;
  padding: 18px 22px;
  color: var(--text);
}
.note-box p { margin: 0; }

/* ---------- Contacts ---------- */
.contact-grid {
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  gap: 40px;
  align-items: start;
}

.contact-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 20px; }
.contact-list li { display: flex; gap: 14px; align-items: flex-start; }
.contact-ico { font-size: 24px; line-height: 1.3; }

.contact-form {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field label { font-weight: 600; font-size: 14px; }

.form-field input,
.form-field select,
.form-field textarea {
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  width: 100%;
}
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
  border-color: var(--brand);
}
.form-field.invalid input,
.form-field.invalid textarea { border-color: var(--bad); }

.form-status {
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 600;
  margin: 0;
}
.form-status.ok { background: rgba(47, 158, 68, 0.12); color: var(--ok); }
.form-status.err { background: rgba(224, 49, 49, 0.1); color: var(--bad); }

/* ---------- Chat ---------- */
.chat-wrap {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  max-width: 820px;
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-alt);
}
.chat-title { margin: 0; font-size: 20px; }
.chat-sub { margin: 2px 0 0; font-size: 13px; }
.chat-sub.online { color: var(--ok); }

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px 22px;
  max-height: 480px;
  overflow-y: auto;
  background: var(--bg);
}

.chat-msg {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--line);
}
.chat-msg.mine {
  align-self: flex-end;
  background: var(--brand-soft);
  border-color: var(--brand);
}
.chat-msg .msg-name { font-weight: 700; font-size: 13px; color: var(--brand); }
.chat-msg .msg-text { margin: 2px 0 4px; word-wrap: break-word; white-space: pre-wrap; }
.chat-msg .msg-ts { font-size: 11px; color: var(--muted); }

.chat-empty {
  text-align: center;
  color: var(--muted);
  padding: 30px 0;
}

.chat-compose {
  border-top: 1px solid var(--line);
  padding: 16px 22px 18px;
  background: var(--card);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-name-row { display: flex; flex-direction: column; gap: 4px; max-width: 260px; }
.chat-name-row input {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}

.chat-send-row { display: flex; gap: 10px; align-items: flex-end; }
.chat-send-row textarea {
  flex: 1;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  resize: vertical;
  min-height: 52px;
}
.chat-send-row textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }

.chat-hint { margin: 0; font-size: 13px; }

/* ---------- Search ---------- */
.search-box {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px;
  max-width: 760px;
}

.search-input-row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.search-ico { font-size: 22px; }
.search-input-row input {
  flex: 1;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
}
.search-input-row input:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }

.search-tabs { display: flex; gap: 8px; margin: 18px 0 14px; }
.search-tab {
  padding: 8px 16px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.search-tab.is-active { background: var(--brand); border-color: var(--brand); color: #fff; }

.search-results { display: flex; flex-direction: column; gap: 10px; }

.search-result {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  padding: 14px 18px;
}
.search-result-title { font-weight: 700; font-size: 16px; }
.search-result-desc { margin: 4px 0 0; color: var(--muted); font-size: 14px; }

.web-search { margin-top: 4px; }
.web-search-grid { display: flex; gap: 10px; flex-wrap: wrap; }

.web-btn {
  padding: 12px 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.web-btn:hover { border-color: var(--brand); }
.web-wiki { border-color: #c9c9c9; }
.web-yandex { border-color: #ffcc00; }
.web-google { border-color: #4285f4; }

/* ---------- Assistant ---------- */
.assistant-fab {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 100;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 26px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(59, 91, 219, 0.4);
  transition: transform 0.2s;
}
.assistant-fab:hover { transform: scale(1.08); }

.assistant-widget {
  position: fixed;
  right: 22px;
  bottom: 92px;
  z-index: 100;
  width: 360px;
  max-width: calc(100vw - 44px);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.assistant-widget[hidden] { display: none; }

.assistant-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
}
.assistant-head button {
  background: none;
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
}

.assistant-chat {
  height: 340px;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg);
}
.assistant-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  word-wrap: break-word;
}
.assistant-msg.bot {
  align-self: flex-start;
  background: var(--card);
  border: 1px solid var(--line);
}
.assistant-msg.user {
  align-self: flex-end;
  background: var(--brand);
  color: #fff;
}
.assistant-msg a { color: var(--brand); font-weight: 600; }

.assistant-input {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: var(--card);
}
.assistant-input input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
.assistant-input input:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
.assistant-input button {
  width: 42px;
  border: none;
  border-radius: 12px;
  background: var(--brand);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
}

@media (max-width: 700px) {
  .assistant-fab { right: 14px; bottom: 14px; width: 52px; height: 52px; font-size: 23px; }
  .assistant-widget { right: 14px; bottom: 76px; width: calc(100vw - 28px); }
  .assistant-chat { height: 300px; }
}

/* ---------- Mobile ---------- */
@media (max-width: 900px) {
  .hero-grid, .contact-grid { grid-template-columns: 1fr; gap: 28px; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filter-search { grid-column: 1 / -1; }
  .footer-grid { grid-template-columns: 1fr; gap: 18px; }
}

@media (max-width: 700px) {
  .nav-toggle { display: block; }

  .main-nav {
    display: none;
    position: absolute;
    top: 68px;
    left: 0;
    right: 0;
    background: var(--card);
    border-bottom: 1px solid var(--line);
    flex-direction: column;
    align-items: stretch;
    padding: 12px 16px 18px;
    gap: 4px;
    box-shadow: var(--shadow);
  }
  .main-nav.open { display: flex; }

  .main-nav a { padding: 12px 14px; border-radius: 10px; }

  .nav-ico { display: inline-block; margin-right: 6px; }

  .filters { grid-template-columns: 1fr; }
  .filter-search { grid-column: auto; }

  .mat-item { grid-template-columns: 1fr; }
  .mat-item .btn { justify-self: start; }

  .section { padding: 40px 0; }
  .trainer-wrap { padding: 22px; }
  .trainer-question { font-size: 24px; }

  .hero { padding: 48px 0; }
}