/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --accent: #2DD4BF;
  --accent-dark: #0d9488;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --bg: #f9fafb;
  --white: #ffffff;
  --green: #059669;
  --green-bg: #ecfdf5;
  --red: #dc2626;
}

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

/* ── Topbar ───────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  height: 60px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.5px;
  color: var(--text);
  text-decoration: none;
}
.logo span { color: var(--accent); }

.user-area {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--muted);
}

.btn-outline {
  background: none;
  border: 1px solid var(--border);
  padding: 5px 14px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  transition: border-color .15s;
}
.btn-outline:hover { border-color: var(--muted); }

/* ── Layout ───────────────────────────────────────────────── */
#app { flex: 1; }

.center-section {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 60px);
  padding: 40px 16px;
}

.page-section {
  max-width: 720px;
  margin: 0 auto;
  padding: 48px 24px;
}

/* ── Login ────────────────────────────────────────────────── */
.login-box {
  text-align: center;
  max-width: 440px;
}
.login-box h1 {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -1px;
  margin-bottom: 14px;
  line-height: 1.2;
}
.login-box p {
  color: var(--muted);
  margin-bottom: 36px;
  font-size: 16px;
}

.btn-tg {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: #229ED9;
  color: #fff;
  border: none;
  padding: 14px 28px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, transform .1s;
}
.btn-tg:hover { background: #1a8bbf; }
.btn-tg:active { transform: scale(.97); }
.btn-tg svg { width: 22px; height: 22px; fill: #fff; flex-shrink: 0; }

.pending { font-size: 14px; color: var(--muted); min-height: 24px; margin-top: 20px; }

/* ── Course card ──────────────────────────────────────────── */
h2 { font-size: 22px; font-weight: 700; margin-bottom: 24px; }

.course-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  cursor: pointer;
  transition: box-shadow .2s, transform .15s;
}
.course-card:hover { box-shadow: 0 6px 20px rgba(0,0,0,.08); transform: translateY(-1px); }
.course-card h3 { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.course-card p { color: var(--muted); font-size: 14px; }

.tag {
  display: inline-block;
  background: var(--green-bg);
  color: var(--green);
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  margin-bottom: 10px;
  letter-spacing: .3px;
}

/* ── Breadcrumb ───────────────────────────────────────────── */
.breadcrumb {
  display: inline-block;
  color: var(--muted);
  font-size: 14px;
  text-decoration: none;
  margin-bottom: 24px;
  transition: color .15s;
}
.breadcrumb:hover { color: var(--text); }

/* ── Module cards ─────────────────────────────────────────── */
.modules-list { display: flex; flex-direction: column; gap: 14px; }

.module-card {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 22px 24px;
  position: relative;
  overflow: hidden;
  transition: box-shadow .2s, transform .15s;
}

.module-card.available {
  cursor: pointer;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(45,212,191,.12);
  animation: pulse-border 2.5s ease-in-out infinite;
}
.module-card.available:hover { box-shadow: 0 6px 20px rgba(45,212,191,.2); transform: translateY(-1px); }

@keyframes pulse-border {
  0%, 100% { box-shadow: 0 0 0 3px rgba(45,212,191,.12); }
  50%       { box-shadow: 0 0 0 6px rgba(45,212,191,.22); }
}

.module-card.locked {
  opacity: .55;
  cursor: default;
  filter: grayscale(.3);
}

.module-card.passed { cursor: pointer; }
.module-card.passed:hover { box-shadow: 0 4px 14px rgba(0,0,0,.07); transform: translateY(-1px); }

.module-num {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .8px;
  margin-bottom: 6px;
}
.module-card h3 { font-size: 17px; font-weight: 700; margin-bottom: 4px; }
.module-card p  { font-size: 14px; color: var(--muted); }

.lock-icon {
  position: absolute;
  top: 22px; right: 22px;
  font-size: 20px;
  opacity: .4;
}

/* Stamp "Пройден" */
.stamp {
  position: absolute;
  top: 16px; right: 16px;
  background: transparent;
  border: 3px solid var(--green);
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 4px;
  transform: rotate(-5deg);
  opacity: .75;
  pointer-events: none;
  user-select: none;
}

/* ── Lesson content ───────────────────────────────────────── */
.lesson-content {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 40px 48px;
  margin-bottom: 32px;
}

.lesson-content h1 { font-size: 26px; font-weight: 800; margin-bottom: 24px; letter-spacing: -.5px; }
.lesson-content h2 { font-size: 18px; font-weight: 700; margin: 28px 0 12px; }
.lesson-content h3 { font-size: 16px; font-weight: 700; margin: 20px 0 8px; }
.lesson-content p  { margin-bottom: 16px; color: #1f2937; line-height: 1.75; }
.lesson-content ul, .lesson-content ol { padding-left: 22px; margin-bottom: 16px; }
.lesson-content li { margin-bottom: 6px; line-height: 1.65; }
.lesson-content hr { border: none; border-top: 1px solid var(--border); margin: 28px 0; }

.lesson-content blockquote {
  border-left: 3px solid var(--accent);
  margin: 20px 0;
  padding: 12px 20px;
  background: #f0fdfb;
  border-radius: 0 8px 8px 0;
  color: #374151;
  font-style: italic;
}

/* Code blocks */
.lesson-content pre {
  background: #111827;
  color: #e5e7eb;
  border-radius: 10px;
  padding: 48px 24px 20px; /* top padding для кнопки */
  margin: 20px 0;
  font-size: 14px;
  line-height: 1.6;
  position: relative;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-x: hidden;
}
.lesson-content code {
  font-family: "SF Mono", "Fira Code", "Cascadia Code", monospace;
  font-size: 13.5px;
  white-space: pre-wrap;
  word-break: break-word;
}
.lesson-content p code, .lesson-content li code {
  background: #f3f4f6;
  color: #dc2626;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}

/* Copy button */
.code-wrapper { position: relative; }
.copy-btn {
  position: absolute;
  top: 12px; right: 12px;
  background: rgba(255,255,255,.12);
  border: none;
  color: #9ca3af;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: background .15s, color .15s;
  z-index: 1;
}
.copy-btn:hover { background: rgba(255,255,255,.22); color: #fff; }
.copy-btn.copied { color: var(--accent); }

/* Prompt block */
.prompt-block {
  background: #fffbeb;
  border: 1.5px dashed #f59e0b;
  border-radius: 10px;
  padding: 18px 20px;
  margin: 20px 0;
  position: relative;
}
.prompt-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #92400e;
  margin-bottom: 8px;
}

/* Lesson footer */
.lesson-footer {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  padding-bottom: 60px;
}

.btn-next {
  background: var(--accent);
  color: var(--white);
  border: none;
  padding: 14px 32px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background .2s, transform .1s;
  letter-spacing: -.2px;
}
.btn-next:hover { background: var(--accent-dark); }
.btn-next:active { transform: scale(.97); }

.ping-result {
  font-size: 15px;
  padding: 12px 20px;
  border-radius: 10px;
  width: 100%;
  text-align: center;
}
.ping-result.success { background: var(--green-bg); color: var(--green); font-weight: 600; }
.ping-result.error   { background: #fef2f2; color: var(--red); }

/* ── Lessons list ─────────────────────────────────────────── */
.module-header { margin-bottom: 32px; }
.module-header h2 { font-size: 24px; font-weight: 800; margin-bottom: 6px; }
.module-header p  { color: var(--muted); font-size: 15px; }

.lessons-section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--muted);
  margin-bottom: 12px;
}

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

.lesson-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  cursor: pointer;
  transition: box-shadow .15s, border-color .15s;
  text-decoration: none;
  color: var(--text);
}
.lesson-row:hover { box-shadow: 0 2px 10px rgba(0,0,0,.07); border-color: #d1d5db; }

.lesson-row.locked {
  cursor: default;
  color: #9ca3af;
  background: #fafafa;
}
.lesson-row.locked:hover { box-shadow: none; border-color: var(--border); }

.lesson-row-title { font-size: 15px; font-weight: 500; }
.lesson-row.locked .lesson-row-title { font-weight: 400; }

.lesson-check {
  color: var(--accent);
  font-size: 18px;
  font-weight: 700;
  flex-shrink: 0;
  margin-left: 12px;
}

/* ── Mobile ───────────────────────────────────────────────── */
@media (max-width: 640px) {
  .topbar { padding: 0 16px; }
  .page-section { padding: 32px 16px; }
  .lesson-content { padding: 24px 20px; }
  .lesson-content h1 { font-size: 22px; }
  .login-box h1 { font-size: 26px; }
}
