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

:root {
  --bg: #ffffff;
  --bg-secondary: #f7f6f3;
  --text: #37352f;
  --text-secondary: #787774;
  --border: #e9e9e7;
  --accent: #2383e2;
  --accent-light: #e7f3fe;
  --danger: #eb5757;
  --radius: 10px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 16px 80px;
  min-height: 100vh;
}

/* ─── Общие элементы ─────────────────────────────────────────────────── */

.screen {
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.top-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding-top: 8px;
}

.back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--bg-secondary);
  border: none;
  cursor: pointer;
  color: var(--text);
  font-size: 18px;
  flex-shrink: 0;
}
.back-btn:active { background: var(--border); }

.page-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.page-subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 2px;
}

/* ─── Загрузка / ошибки ──────────────────────────────────────────────── */

.center-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 70vh;
  text-align: center;
  gap: 12px;
  padding: 24px;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ─── Главный экран: список модулей ──────────────────────────────────── */

.hero {
  background: linear-gradient(135deg, #2383e2 0%, #1a6bc4 100%);
  border-radius: var(--radius);
  padding: 24px 20px;
  color: white;
  margin-bottom: 24px;
}
.hero h1 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 6px;
}
.hero p {
  font-size: 14px;
  opacity: 0.9;
}

.module-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: background 0.15s;
}
.module-card:active { background: var(--border); }

.module-card-text { flex: 1; }

.module-card-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 2px;
}

.module-card-count {
  font-size: 13px;
  color: var(--text-secondary);
}

.module-card-arrow {
  color: var(--text-secondary);
  font-size: 18px;
  flex-shrink: 0;
}

/* ─── Список уроков ───────────────────────────────────────────────────── */

.lesson-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.lesson-row:last-child { border-bottom: none; }
.lesson-row:active { background: var(--bg-secondary); }

.lesson-row-number {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.lesson-row-title {
  font-size: 15px;
  flex: 1;
}

/* ─── Экран урока ──────────────────────────────────────────────────────── */

.lesson-content {
  font-size: 16px;
}

.block-text {
  white-space: pre-wrap;
  margin-bottom: 16px;
}

.block-photo {
  width: 100%;
  border-radius: var(--radius);
  margin-bottom: 16px;
  display: block;
  border: 1px solid var(--border);
}

.lesson-nav {
  display: flex;
  gap: 10px;
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.nav-btn {
  flex: 1;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  color: var(--text);
}
.nav-btn:active { background: var(--border); }
.nav-btn.primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* ─── Оплата ──────────────────────────────────────────────────────────── */

.paywall {
  text-align: center;
  padding: 40px 20px;
}
.paywall h2 {
  font-size: 20px;
  margin-bottom: 8px;
}
.paywall p {
  color: var(--text-secondary);
  margin-bottom: 24px;
}
.price-tag {
  font-size: 32px;
  font-weight: 800;
  margin-bottom: 24px;
}

.btn {
  display: inline-block;
  padding: 14px 28px;
  border-radius: var(--radius);
  background: var(--accent);
  color: white;
  font-weight: 600;
  font-size: 15px;
  border: none;
  cursor: pointer;
}

/* ─── Режим редактора (виден только админу) ──────────────────────────── */

.editor-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  border: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  cursor: pointer;
  z-index: 50;
}

.edit-block-wrap {
  position: relative;
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 12px;
}

.edit-block-controls {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.edit-block-controls button {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  cursor: pointer;
  color: var(--text);
}
.edit-block-controls button.danger { color: var(--danger); }

.edit-textarea {
  width: 100%;
  min-height: 80px;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 15px;
  resize: vertical;
  color: var(--text);
  outline: none;
}

.add-block-row {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.add-block-btn {
  flex: 1;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px dashed var(--accent);
  background: var(--accent-light);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.save-bar {
  position: sticky;
  bottom: 0;
  background: var(--bg);
  padding: 12px 0;
  border-top: 1px solid var(--border);
  margin-top: 16px;
}

.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: white;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 100;
  animation: fadeIn 0.2s ease;
}
