/* ===== Variables ===== */
:root {
  --bg: #f8f9fa;
  --surface: #ffffff;
  --text: #1a1a1a;
  --text-secondary: #5a5a5a;
  --border: #e2e4e8;
  --primary: #1e3a8a;
  --primary-light: #dbeafe;
  --accent: #dc2626;
  --accent-light: #fee2e2;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #ca8a04;
  --warning-light: #fef9c3;
  --radius: 12px;
  --shadow: 0 4px 20px rgba(0,0,0,0.06);
  --shadow-hover: 0 8px 30px rgba(0,0,0,0.10);
  --transition: 0.2s ease;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
}

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

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 1.2rem;
}

.logo-img {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: block;
}

.logo-text {
  letter-spacing: -0.02em;
}

.main-nav {
  display: flex;
  gap: 6px;
}

.main-nav a {
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 8px;
  transition: var(--transition);
}

.main-nav a:hover,
.main-nav a.active {
  color: var(--primary);
  background: var(--primary-light);
}

.menu-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
}

.menu-toggle span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: var(--transition);
}

/* ===== Main ===== */
main {
  flex: 1;
  padding: 32px 0 48px;
}

.page-title {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.page-subtitle {
  color: var(--text-secondary);
  margin-bottom: 28px;
  font-size: 1.05rem;
}

.section-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 32px 0 16px;
}

/* ===== Cards ===== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  transition: var(--transition);
  cursor: pointer;
}

.card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
  border-color: var(--primary-light);
}

.card[data-goto] {
  position: relative;
}

.card[data-goto]::after {
  content: '→';
  position: absolute;
  right: 18px;
  bottom: 16px;
  color: var(--primary);
  font-size: 1rem;
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity var(--transition), transform var(--transition);
}

.card[data-goto]:hover::after {
  opacity: 1;
  transform: translateX(0);
}

.card h3 {
  font-size: 1.15rem;
  margin-bottom: 8px;
  color: var(--primary);
}

.card p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.5;
}

.card .meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--primary-light);
  color: var(--primary);
}

.badge-accent {
  background: var(--accent-light);
  color: var(--accent);
}

.badge-success {
  background: var(--success-light);
  color: var(--success);
}

.badge-warning {
  background: var(--warning-light);
  color: var(--warning);
}

/* ===== Hero ===== */
.hero {
  background: linear-gradient(135deg, var(--primary) 0%, #172554 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 48px 40px;
  margin-bottom: 32px;
  box-shadow: var(--shadow);
}

.hero h1 {
  font-size: 2.2rem;
  font-weight: 800;
  margin-bottom: 14px;
  max-width: 700px;
}

.hero p {
  font-size: 1.15rem;
  opacity: 0.9;
  max-width: 700px;
  margin-bottom: 24px;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: var(--transition);
}

.btn-primary {
  background: #fff;
  color: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-light);
}

.btn-secondary {
  background: rgba(255,255,255,0.15);
  color: #fff;
}

.btn-secondary:hover {
  background: rgba(255,255,255,0.25);
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}

.btn-outline:hover {
  background: var(--primary-light);
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-success:hover {
  background: #15803d;
}

.btn-danger {
  background: var(--accent);
  color: #fff;
}

.btn-danger:hover {
  background: #b91c1c;
}

/* ===== Search & filters ===== */
.search-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.search-bar input,
.search-bar select {
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  background: var(--surface);
  color: var(--text);
  flex: 1;
  min-width: 200px;
}

.search-bar input:focus,
.search-bar select:focus {
  outline: none;
  border-color: var(--primary);
}

/* ===== Topic page ===== */
.topic-detail {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.topic-detail h2 {
  font-size: 1.8rem;
  margin-bottom: 8px;
  color: var(--primary);
}

.topic-detail h3 {
  font-size: 1.25rem;
  margin: 28px 0 12px;
  color: var(--text);
}

.topic-detail p {
  margin-bottom: 12px;
}

.topic-detail ul,
.topic-detail ol {
  margin: 12px 0 12px 24px;
}

.topic-detail li {
  margin-bottom: 6px;
}

.topic-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  flex-wrap: wrap;
}

/* ===== Test ===== */
.test-container {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.question {
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.question:last-child {
  border-bottom: none;
}

.question-text {
  font-weight: 700;
  font-size: 1.05rem;
  margin-bottom: 14px;
}

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

.option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition);
  background: var(--bg);
}

.option:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.option input {
  margin-top: 3px;
}

.option.correct {
  border-color: var(--success);
  background: var(--success-light);
}

.option.wrong {
  border-color: var(--accent);
  background: var(--accent-light);
}

.explanation {
  margin-top: 12px;
  padding: 14px;
  background: var(--primary-light);
  border-radius: 8px;
  font-size: 0.95rem;
  display: none;
}

.explanation.visible {
  display: block;
}

.test-result {
  margin-top: 24px;
  padding: 20px;
  border-radius: 8px;
  font-weight: 700;
  text-align: center;
  font-size: 1.1rem;
}

/* ===== Progress ===== */
.progress-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  text-align: center;
}

.stat-card .number {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
}

.stat-card .label {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-top: 4px;
}

.progress-list {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
}

.progress-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
}

.progress-item:last-child {
  border-bottom: none;
}

.progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  width: 140px;
}

.progress-bar > div {
  height: 100%;
  background: var(--success);
  border-radius: 4px;
  transition: width 0.4s ease;
}

/* ===== Footer ===== */
.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 24px 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.footer-links {
  margin-top: 8px;
}

.footer-links a {
  color: var(--primary);
  text-decoration: none;
  margin-right: 16px;
}

.footer-links a:hover {
  text-decoration: underline;
}

.age-rating {
  display: inline-block;
  border: 1.5px solid currentColor;
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.4;
  opacity: 0.7;
  vertical-align: middle;
}

/* ===== Empty state ===== */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-secondary);
}

.empty-state h3 {
  color: var(--text);
  margin-bottom: 8px;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .menu-toggle {
    display: flex;
  }

  .main-nav {
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 12px 20px;
    gap: 4px;
    display: none;
  }

  .main-nav.open {
    display: flex;
  }

  .hero {
    padding: 32px 24px;
  }

  .hero h1 {
    font-size: 1.6rem;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }

  .topic-detail,
  .test-container {
    padding: 22px;
  }

  .ai-chat-window {
    width: calc(100vw - 24px);
    right: 12px;
    bottom: 84px;
    max-height: calc(100vh - 110px);
  }
}

/* ===== AI-юрист: плавающий чат ===== */
.ai-chat-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.ai-chat-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 50px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-hover);
  transition: transform var(--transition), box-shadow var(--transition);
}

.ai-chat-toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(30, 58, 138, 0.25);
}

.ai-chat-window {
  position: absolute;
  bottom: 72px;
  right: 0;
  width: 380px;
  max-height: 560px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-hover);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(0.96);
  transition: opacity var(--transition), transform var(--transition), visibility var(--transition);
}

.ai-chat-window.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.ai-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--primary);
  color: #fff;
}

.ai-chat-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 1rem;
}

.ai-chat-close {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}

.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f8fafc;
}

.ai-message {
  display: flex;
  max-width: 92%;
}

.ai-message-user {
  align-self: flex-end;
}

.ai-message-system,
.ai-message-assistant {
  align-self: flex-start;
}

.ai-message-content {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.92rem;
  line-height: 1.5;
  word-wrap: break-word;
}

.ai-message-user .ai-message-content {
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.ai-message-system .ai-message-content,
.ai-message-assistant .ai-message-content {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.ai-message-content p {
  margin: 0;
}

.ai-message-content p + p {
  margin-top: 0.6em;
}

.ai-message-content ul,
.ai-message-content ol {
  margin: 0.5em 0 0.5em 1.2em;
}

.ai-message-content li {
  margin-bottom: 0.25em;
}

.ai-chat-input-area {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.ai-chat-input-wrap {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.ai-chat-input {
  flex: 1;
  resize: none;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.95rem;
  line-height: 1.4;
  max-height: 120px;
  min-height: 42px;
  background: #fff;
  color: var(--text);
  font-family: inherit;
}

.ai-chat-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.ai-chat-send {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background var(--transition);
  flex-shrink: 0;
}

.ai-chat-send:hover {
  background: #152c6e;
}

.ai-chat-send:disabled {
  background: #94a3b8;
  cursor: not-allowed;
}

.ai-chat-hint {
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.3;
}

.ai-chat-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
}

.ai-chat-typing span {
  width: 7px;
  height: 7px;
  background: var(--text-secondary);
  border-radius: 50%;
  animation: aiTyping 1.2s infinite ease-in-out;
}

.ai-chat-typing span:nth-child(2) {
  animation-delay: 0.2s;
}

.ai-chat-typing span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes aiTyping {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

.ai-chat-consent {
  position: absolute;
  inset: 0;
  top: 53px; /* below header */
  background: var(--surface);
  z-index: 5;
  display: none;
  flex-direction: column;
  padding: 20px 18px 18px;
  gap: 14px;
}

.ai-chat-consent-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  margin: 0;
}

.ai-chat-consent-list {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 0.83rem;
  color: var(--text-secondary);
  flex: 1;
}

.ai-chat-consent-list li {
  line-height: 1.4;
}

.ai-chat-consent-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text);
  cursor: pointer;
}

.ai-chat-consent-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--primary);
  flex-shrink: 0;
}

.ai-chat-consent-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--transition);
}

.ai-chat-consent-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.ai-chat-consent-btn:not(:disabled):hover {
  opacity: 0.88;
}

.ai-chat-error {
  color: var(--accent);
  font-size: 0.85rem;
  margin-top: 6px;
}

.ai-chat-setup {
  padding: 12px;
  background: var(--warning-light);
  border: 1px solid var(--warning);
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--text);
}

.ai-chat-setup a {
  color: var(--primary);
  text-decoration: underline;
}

.ai-chat-empty {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.85rem;
  padding: 20px;
}
}

/* ===== Olympiad Detail ===== */
.olympiad-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}

.olympiad-reg-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.olympiad-reg-school {
  border-left-color: var(--text-secondary);
}

.olympiad-reg-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.olympiad-reg-date {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary);
}

.olympiad-reg-note {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.olympiad-reg-countdown {
  display: inline-block;
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 0.8rem;
  font-weight: 600;
}

.olympiad-reg-neutral { background: var(--bg); color: var(--text-secondary); }
.olympiad-reg-active  { background: #d1fae5; color: #065f46; }
.olympiad-reg-today   { background: #fef9c3; color: #713f12; }
.olympiad-reg-soon    { background: #fee2e2; color: #991b1b; }
.olympiad-reg-near    { background: #fef3c7; color: #92400e; }

.olympiad-tg-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #2AABEE;
  color: #fff;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  transition: opacity var(--transition);
  width: fit-content;
}

.olympiad-tg-link:hover { opacity: 0.88; }

/* ===== Checker: Мои льготы ===== */
.checker-mode-switcher {
  display: flex;
  gap: 10px;
  margin: 20px 0 0;
}

.checker-mode-btn {
  padding: 10px 22px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.checker-mode-btn.active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}

.checker-mode-btn:hover:not(.active) {
  border-color: var(--primary);
  color: var(--primary);
}

.checker-form {
  margin: 16px 0 32px;
}

.checker-select {
  width: 100%;
  max-width: 560px;
  padding: 12px 16px;
  font-size: 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: border-color var(--transition);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7280' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}

.checker-select:focus {
  outline: none;
  border-color: var(--primary);
}

.checker-olympiad-info {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 8px;
}

.checker-olympiad-header {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.checker-olympiad-header h2 {
  margin: 0;
  font-size: 1.3rem;
  color: var(--primary);
}

.checker-olympiad-info p {
  margin: 6px 0 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.checker-benefits-box {
  margin-top: 14px;
  background: var(--bg);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text);
}

.checker-uni-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.checker-uni-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.checker-uni-name {
  font-size: 1.1rem;
  margin: 0 0 6px;
  color: var(--text);
}

.checker-context {
  font-size: 0.88rem;
  background: var(--primary-light);
  color: var(--primary-dark, var(--primary));
  border-radius: 6px;
  padding: 7px 12px;
  margin-bottom: 10px;
}

.checker-note {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 8px;
}

.checker-ege {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.checker-empty {
  color: var(--text-secondary);
  font-style: italic;
  padding: 20px 0;
}

/* ===== Bot CTA Banner (home page) ===== */
.bot-cta-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  background: linear-gradient(135deg, #0088cc 0%, #006aaa 100%);
  color: #fff;
  border-radius: 14px;
  padding: 18px 24px;
  margin: 24px 0 8px;
}
.bot-cta-icon {
  flex-shrink: 0;
  opacity: 0.9;
}
.bot-cta-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.bot-cta-text strong {
  font-size: 1rem;
  font-weight: 700;
}
.bot-cta-text span {
  font-size: 0.88rem;
  opacity: 0.9;
}
.bot-cta-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.btn-tg {
  background: #fff;
  color: #0088cc;
  font-weight: 700;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  font-size: 0.9rem;
  transition: opacity 0.15s;
}
.btn-tg:hover { opacity: 0.88; }
.btn-tg.btn-lg { padding: 13px 28px; font-size: 1rem; }
.btn-outline-dark {
  background: transparent;
  color: #fff;
  border: 2px solid rgba(255,255,255,0.6);
  padding: 8px 18px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: border-color 0.15s, background 0.15s;
}
.btn-outline-dark:hover { border-color: #fff; background: rgba(255,255,255,0.12); }
@media (max-width: 600px) {
  .bot-cta-banner {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .bot-cta-actions { width: 100%; }
  .btn-tg, .btn-outline-dark { flex: 1; justify-content: center; text-align: center; }
}

/* ===== Bot page ===== */
.bot-page-hero {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  background: linear-gradient(135deg, #0088cc 0%, #005fa3 100%);
  color: #fff;
  border-radius: 16px;
  padding: 32px;
  margin-bottom: 8px;
}
.bot-page-icon {
  flex-shrink: 0;
  background: rgba(255,255,255,0.15);
  border-radius: 50%;
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.bot-page-hero-text h2 {
  margin: 0 0 8px;
  font-size: 1.5rem;
}
.bot-page-hero-text p {
  margin: 0 0 20px;
  opacity: 0.9;
  line-height: 1.6;
}
@media (max-width: 600px) {
  .bot-page-hero { flex-direction: column; padding: 24px; }
  .bot-page-icon { width: 60px; height: 60px; }
}

.bot-feature-card { text-align: center; }
.bot-feature-icon { font-size: 2rem; margin-bottom: 8px; }

.bot-steps {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 0 0 32px;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.bot-step {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 24px;
  background: var(--card-bg, #fff);
  border-bottom: 1px solid var(--border);
}
.bot-step:last-child { border-bottom: none; }
.bot-step-num {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #0088cc;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
}
.bot-step-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.bot-step-text strong { font-size: 0.95rem; }
.bot-step-text span { font-size: 0.85rem; color: var(--text-secondary); }
.bot-step-text a { color: #0088cc; text-decoration: none; }
.bot-step-text a:hover { text-decoration: underline; }

.bot-cta-final {
  text-align: center;
  margin: 8px 0 40px;
}

/* Nav bot link highlight */
.main-nav .nav-bot-link {
  color: #0088cc;
  font-weight: 600;
}
.main-nav .nav-bot-link.active {
  border-color: #0088cc;
}

/* ===== Loading Screen ===== */
#page-loader {
  position: fixed;
  inset: 0;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.45s ease, visibility 0.45s ease;
}
#page-loader.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.loader-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
  animation: loaderFadeUp 0.4s ease both;
}
.loader-logo img {
  width: 48px;
  height: 48px;
  border-radius: 10px;
}
.loader-logo span {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.03em;
}
.loader-dots {
  display: flex;
  gap: 8px;
}
.loader-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  animation: loaderPulse 1.2s ease-in-out infinite;
}
.loader-dots span:nth-child(2) { animation-delay: 0.2s; }
.loader-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes loaderPulse {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.35; }
  40% { transform: scale(1); opacity: 1; }
}
@keyframes loaderFadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Page fade-in transition ===== */
@keyframes pageFadeIn {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}
#app.page-enter {
  animation: pageFadeIn 0.25s ease forwards;
}

/* ===== Button animations ===== */
.btn:hover {
  transform: translateY(-1px);
}
.btn:active {
  transform: scale(0.96) translateY(0) !important;
  transition: transform 0.08s ease !important;
}

/* ===== Nav link hover underline ===== */
.main-nav a {
  position: relative;
}
.main-nav a::after {
  content: '';
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 4px;
  height: 2px;
  background: var(--primary);
  border-radius: 1px;
  transform: scaleX(0);
  transition: transform 0.2s ease;
  transform-origin: center;
}
.main-nav a:hover::after,
.main-nav a.active::after {
  transform: scaleX(1);
}

/* ===== Card pulse on click ===== */
.card:active {
  transform: scale(0.98) translateY(0) !important;
  transition: transform 0.1s ease !important;
}

/* ===== Theme toggle button ===== */
.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}
.theme-toggle:hover {
  background: var(--primary-light);
  color: var(--primary);
}
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
body.dark .theme-toggle .icon-sun { display: block; }
body.dark .theme-toggle .icon-moon { display: none; }

/* ===== Dark theme ===== */
body.dark {
  --bg: #0e1117;
  --surface: #1a1d2e;
  --text: #e2e8f0;
  --text-secondary: #8b95a6;
  --border: #2d3454;
  --primary: #4f8ef7;
  --primary-light: #1a2d50;
  --accent: #f87171;
  --accent-light: #3b1515;
  --success: #34d399;
  --success-light: #0d3b2e;
  --warning: #fbbf24;
  --warning-light: #2d1f00;
  --shadow: 0 4px 20px rgba(0,0,0,0.45);
  --shadow-hover: 0 8px 30px rgba(0,0,0,0.65);
}

body.dark .hero {
  background: linear-gradient(135deg, #1e3a8a 0%, #0f172a 100%);
}

body.dark .ai-message-system .ai-message-content,
body.dark .ai-message-assistant .ai-message-content {
  background: #242840;
  border-color: var(--border);
}

body.dark .ai-chat-input {
  background: var(--bg);
}

body.dark .ai-chat-send:hover {
  background: #3b70e0;
}

body.dark .olympiad-reg-active { background: #0d3b2e; color: #34d399; }
body.dark .olympiad-reg-today  { background: #2d1f00; color: #fbbf24; }
body.dark .olympiad-reg-soon   { background: #3b1515; color: #f87171; }
body.dark .olympiad-reg-near   { background: #2a1800; color: #fb923c; }

/* Smooth transition when switching themes */
.theme-transitioning,
.theme-transitioning *:not(.loader-dots span):not(.ai-chat-typing span) {
  transition: background-color 0.3s ease, color 0.25s ease,
              border-color 0.3s ease, box-shadow 0.3s ease !important;
}

/* ===== Practice (пробники) ===== */
.practice-container { max-width: 860px; margin: 0 auto; }

.practice-part {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  margin-bottom: 32px;
}

.practice-part-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent);
  margin: 0 0 8px;
}

.practice-part-instructions {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.5;
}

.practice-part-meta {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.practice-task {
  border-top: 1px solid var(--border);
  padding-top: 24px;
  margin-top: 24px;
}

.practice-task:first-child {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}

.practice-task-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 12px;
  color: var(--text-secondary);
}

.practice-task-text {
  line-height: 1.7;
  margin-bottom: 18px;
}

.practice-answer-area { display: flex; flex-direction: column; gap: 10px; }

.practice-answer-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.practice-textarea {
  width: 100%;
  min-height: 120px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.6;
  resize: vertical;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

.practice-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.practice-textarea-large { min-height: 200px; }

.practice-ai-btn { align-self: flex-start; }

.ai-evaluation {
  border-radius: var(--radius);
  overflow: hidden;
}

.ai-eval-notice, .ai-eval-loading, .ai-eval-error {
  padding: 14px 16px;
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.ai-eval-notice { background: var(--info-light, #eff6ff); color: var(--accent); }
.ai-eval-loading { background: var(--surface); color: var(--text-secondary); font-style: italic; }
.ai-eval-error { background: #fef2f2; color: #dc2626; }

.ai-eval-result {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.ai-eval-header {
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.ai-eval-content {
  padding: 16px;
  font-size: 0.93rem;
  line-height: 1.7;
  background: var(--surface);
}

body.dark .practice-textarea { background: var(--bg); }
body.dark .ai-eval-notice { background: #1e3a5f; color: #93c5fd; }
body.dark .ai-eval-error { background: #3b0f0f; color: #f87171; }
body.dark .ai-eval-content { background: #1e2030; }
