/* =========================
   BASE
========================= */


:root{

  --bg:#f8f8fb;
  --text:#222;
  --muted:#666;

  --accent:#d9534f;
  --accent-2:#ff7a59;

  --surface:#ffffff;
  --surface-2:#f6f4f9;
  --accent-soft: rgba(76,110,245,0.12);

  --card:var(--surface);

  --border:var(--surface-2);

  --text-2:#1f2937;
  --text-muted:#6b7280;
}


* { box-sizing:border-box; }


/* === App Loader === */

#app-loader {
  position: fixed;
  inset: 0;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity .4s ease, visibility .4s ease;
}

#app-loader.hidden {
  opacity: 0;
  visibility: hidden;
}

.loader-card {
  background: var(--surface);
  padding: 40px 36px;
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: loaderFade .6s ease;
}

.loader-logo {
  font-size: 40px;
  margin-bottom: 12px;
}

.loader-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 24px;
  color: var(--text);
}

.loader-spinner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top: 3px solid #d9cce0;
  animation: spin 0.8s linear infinite;
}

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

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

body{
  margin:0;
  font-family: Inter, system-ui, "Segoe UI", Roboto, Arial;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing:antialiased;
}

h1{
  margin:0 0 16px;
  font-size:28px;
}

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

.container{
  max-width:1200px;
  margin:24px auto;
  padding:0 24px;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}


/* =========================
   HEADER
========================= */
.site-header{
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header-inner{
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:12px 0;
}

.brand{
  font-weight:800;
  font-size:20px;
  text-decoration:none;
  color:var(--text);
}

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

.main-nav a{
  text-decoration:none;
  color:var(--text);
  padding:6px 10px;
  border-radius:6px;
}

.main-nav a:hover{
  background:var(--surface-2);
}

/* =========================
   BUTTONS
========================= */
.btn{
  padding:6px 10px;
  border-radius:6px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor:pointer;
}

.btn.primary{
  background:var(--accent);
  color:var(--surface);
  border:none;
}

.btn.small{
  padding:4px 6px;
  font-size:12px;
}

/* =========================
   ADMIN (TABLES)
========================= */
table{
  width:100%;
  border-collapse:collapse;
  background: var(--surface);
  border-radius:8px;
  overflow:hidden;
}

th, td{
  padding:10px 12px;
  border-bottom:1px solid var(--border);
  font-size:13px;
  vertical-align:middle;
}

th{
  background: var(--surface-2);
  font-weight:600;
  text-align:left;
}

.admin-toolbar{
  display:flex;
  gap:12px;
  align-items:center;
  margin-bottom:16px;
}

tr.frozen{
  opacity:.6;
  background:#f1f5f9 !important;
}

tr.risk-high{
  background:rgba(220,38,38,.06);
}

tr.risk-medium{
  background:rgba(245,158,11,.08);
}

/* =========================
   TG-STYLE LESSON CARDS
========================= */
.page-title{
  margin:12px 0 20px;
}

.tg-cards{
  display:grid;
  grid-template-columns:repeat(auto-fill, minmax(220px,1fr));
  gap:16px;
}

.tg-card{
  display:block;
  background: var(--surface);
  box-shadow: var(--shadow);
  border-radius:14px;
  overflow:hidden;
  text-decoration:none;
  color:var(--text);
  transition:transform .15s ease, box-shadow .15s ease;
}

.tg-card:hover{
  transform:translateY(-2px);
  box-shadow:0 10px 26px rgba(0,0,0,.12);
}

.tg-card__img{
  position: relative;
  width: 100%;
  padding-top: 100%;      /* 🔥 КВАДРАТ */
  background: var(--surface-2);
  overflow: hidden;
}

.tg-card__img img{
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}


.tg-card__body{
  padding:12px 12px 14px;
}

.tg-card__title{
  font-weight:600;
  font-size:15px;
  line-height:1.3;
  margin-bottom:8px;
}

.tg-card__tags{
  display:flex;
  gap:6px;
  flex-wrap:wrap;
}

.tg-tag{
  font-size:11px;
  padding:4px 8px;
  border-radius:999px;
  background:var(--surface-2);
  color:#555;
}

/* badges */
.badge{
  position:absolute;
  top:8px;
  right:8px;
  background:rgba(0,0,0,.7);
  color:var(--surface);
  font-size:12px;
  padding:6px 8px;
  border-radius:10px;
  pointer-events:none;
}

.badge.done{
  right:44px;
}

/* =========================
   RESPONSIVE
========================= */
@media (max-width:640px){
  .header-inner{
    flex-direction:column;
    align-items:flex-start;
    gap:8px;
  }

  .main-nav{
    flex-wrap:wrap;
  }
}

@media (max-width:480px){
  .tg-cards{
    grid-template-columns:repeat(2,1fr);
    gap:12px;
  }
}

@media (hover:none){
  .tg-card:hover{
    transform:none;
    box-shadow:0 6px 20px rgba(0,0,0,.08);
  }
}


/* =========================
   LESSON FILTERS
========================= */
.lessons-filters{
  display:flex;
  flex-direction:column;
  gap:12px;
  margin-bottom:20px;
}




.tag-filter{
  font-size:12px;
  padding:6px 10px;
  border-radius:999px;
  background:var(--surface-2);
  color:var(--text);
  cursor:pointer;
  user-select:none;
}

.tag-filter.active{
  background:var(--text);
  color:var(--surface);
}

.site-header {
  position: relative;
  z-index: 1000;
}

.tg-card {
  position: relative;
  z-index: 1;
}


/* ===== LESSON PAGE ===== */

.lesson-header {
  margin-bottom: 20px;
}

.lesson-title {
  font-size: 26px;
  margin-bottom: 8px;
}

.lesson-description {
  color: var(--text-muted);
  max-width: 700px;
}

.lesson-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
}

.lesson-video {
  background: var(--surface);
  border-radius: 14px;
  padding: 16px;
}

.lesson-steps {
  background: var(--surface);
  border-radius: 14px;
  padding: 16px;
}

.steps-title {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
}

.steps-count {
  font-size: 13px;
  color: var(--text-muted);
}

.steps-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.step-item a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
}

.step-item a:hover {
  background: var(--surface-2);
}

.step-item.active a {
  background: #eef2ff;
  font-weight: 600;
}

.step-item.completed .step-title {
  opacity: 0.6;
}


.step-check {
  margin-left: auto;
  color: #16a34a;
  font-weight: bold;
}

.step-row {
  display: flex;
  align-items: center;
  justify-content: space-between; /* 🔥 ключевое */
  width: 100%;
}

.step-link {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;              /* 🔥 растягивается */
  min-width: 0;         /* важно для длинных названий */
  text-decoration: none;
  color: var(--text);
}

.step-check-toggle {
  flex-shrink: 0;
  margin-left: 12px;
}



@media (max-width: 900px) {
  .lesson-layout {
    grid-template-columns: 1fr;
  }
}

.lesson-step.done {
  opacity: .6;
}

.lesson-step .check {
  color: #22c55e;
  font-weight: bold;
}

.progress-info {
  font-size: 14px;
  margin-bottom: 6px;
  color: #555;
}


/* ===== Lesson progress ===== */
.lesson-progress {
  margin: 16px 0 24px;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  margin-bottom: 6px;
}

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

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #ff7a59, #d9534f);
  transition: width 0.3s ease;
}


/* WATERMARK */
.video-watermark {
  position: absolute;
  bottom: 12px;
  right: 12px;

  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
  background: rgba(0, 0, 0, 0.25);

  padding: 4px 8px;
  border-radius: 6px;

  pointer-events: none;
  user-select: none;
  z-index: 10;
}


.admin-table {
  width: 100%;
  border-collapse: collapse;
}

.admin-table th,
.admin-table td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
}

.admin-table a {
  color: #4f46e5;
  text-decoration: none;
}

@media (max-width: 768px) {
  .site-header {
    display: none;
  }

  .container {
    margin-top: 16px;
  }
}


@media (max-width: 768px) {
 body {
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}

}

/* iOS: disable fake fullscreen button */
@supports (-webkit-touch-callout: none) {
  #fakeFullscreenBtn {
    display: none !important;
  }
}

/* ===== Compact lesson progress ===== */

.lesson-progress.compact {
  margin-top: 14px;
}

.lesson-progress.compact .progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.progress-text {
  font-size: 13px;
  color: #555;
}

/* нейтральная кнопка */
.progress-btn {
  background: var(--surface-2);
  border: 1px solid #e5e7eb;
  color: var(--text);
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
}

.progress-btn:hover {
  background: var(--surface-2);
}

/* убираем "кричащий" primary-стиль */
.lesson-video .btn.primary {
  background: unset;
  color: inherit;
}

.progress-btn.done {
  background: var(--surface-2);
  color: #6b7280;
  cursor: default;
}


.lesson-progress.compact {
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

/* =========================
   LESSON STEPS — FINAL FIX
========================= */

.step-item {
  margin-bottom: 8px;
}

.step-row {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
}

.step-row:hover {
  background: var(--surface-2);
}

.step-item.active .step-row {
  background: #eef2ff;
}

.step-link {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  text-decoration: none;
  color: var(--text);
}

.step-check-toggle {
  flex-shrink: 0;
  margin-left: 12px;
  display: flex;
  align-items: center;
}

/* custom checkbox */
.step-check-toggle input {
  display: none;
}

.step-check-toggle .checkmark {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 2px solid #c7c7c7;
  background: var(--surface);
  position: relative;
}

.step-check-toggle input:checked + .checkmark {
  background: #22c55e;
  border-color: #22c55e;
}

.step-check-toggle input:checked + .checkmark::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 0px;
  width: 5px;
  height: 10px;
  border: solid var(--surface);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* ===== STEP CARDS (как во 2-м фото) ===== */

.steps-list.cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.step-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border-radius: 14px;
  padding: 10px;
  border: 1px solid var(--border);
  position: relative;
}

.step-card.active {
  background: var(--accent-soft);
}

.step-card.completed {
  opacity: 0.6;
}

.step-card-link {
  display: flex;
  gap: 12px;
  align-items: center;
  flex: 1;
  text-decoration: none;
  color: inherit;
}

.step-thumb {
  width: 72px;
  height: 72px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface-2);
  flex-shrink: 0;
}

.step-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.step-info {
  font-size: 14px;
  line-height: 1.3;
}

.btn.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: #555;
}

.hidden {
  display: none;
}

.admin-step-body input {
  width: 100%;
  padding: 8px 10px;
  margin-bottom: 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 14px;
}

.step-edit-actions {
  display: flex;
  gap: 8px;
}

.admin-step-meta {
  font-size: 13px;
  color: var(--text-muted);
}

.lessons-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, 1fr);
}

/* планшет */
@media (min-width: 768px) {
  .lessons-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* десктоп */
@media (min-width: 1100px) {
  .lessons-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.card-media__image {
  aspect-ratio: 1 / 1;
}
/* большой экран */
@media (min-width: 1500px) {
  .lessons-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

.lesson-card {
  background: var(--surface);
  border-radius: 18px;
  overflow: hidden;
  text-decoration: none;
  color: var(--text-2);
  box-shadow: 0 10px 30px rgba(0,0,0,.04);
  transition: transform .2s ease, box-shadow .2s ease;
}

.lesson-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 18px 40px rgba(0,0,0,.08);
}

.lesson-cover {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: var(--surface-2);
  overflow: hidden;
}

.lesson-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.lesson-body {
  padding: 16px 18px 20px;
}

.lesson-title {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
}

.lesson-subtitle {
  margin-top: 6px;
  font-size: 13px;
  color: #6b7280;
}

.lessons-list-panel {
  background: var(--surface);
  border-radius: 24px;
  padding: 24px;
  box-shadow: 0 14px 40px rgba(0,0,0,.05);
}



.lessons-list-panel .lesson-card {
  box-shadow: none;
  border: 1px solid var(--border);
}

.lessons-list-panel .lesson-card:hover {
  box-shadow: 0 10px 26px rgba(0,0,0,.08);
}


.step-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
}


.admin-textarea {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
background: var(--surface);
color: var(--text);
  font-size: 14px;
  resize: vertical;
}

.admin-textarea:focus {
  outline: none;
  border-color: #6b4eff;
}

html,
body {
  overflow-x: hidden;
}

/* =========================================
   BASE PAGE CONTAINER
========================================= */

.page-container {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 16px clamp(16px, 3vw, 32px) 96px;
  box-sizing: border-box;
}

/* узкий вариант */
.page-container--narrow {
  max-width: 720px;
}

/* широкий (админка) */
.page-container--wide {
  max-width: 1100px;
}

@import url('./bottom-nav.css');



body[data-entity="recipes"] .container {
  padding: 18px 16px 32px;
}

.tg-body.section-items > * + * {
  margin-top: 16px;
}

/* ===== CARD APPEAR ANIMATION ===== */

.card-appear {
  opacity: 0;
  transform: translateY(20px) scale(0.96);
  filter: blur(6px);

  transition:
    opacity .45s cubic-bezier(.2,.8,.2,1),
    transform .45s cubic-bezier(.2,.8,.2,1),
    filter .45s ease;
}

.card-appear.show {
  opacity: 1;
  transform: translateY(0) scale(1);
  filter: blur(0);
}

[data-theme="dark"] {

  --bg:#111213;
  --text:#f1f1f1;
  --muted:#aaa;
  --accent-soft: rgba(123,140,255,0.18);
  --card:#1b1c1e;
  --surface:#1b1c1e;
  --surface-2:#202124;

  --border:#2a2b2e;

  --text-2:#d1d5db;
  --text-muted:#9ca3af;

  --accent:#ff7a59;
  --accent-2:#ff9b7f;

  --shadow-sm:none;
  --shadow:none;
  --shadow-lg:none;

  --overlay:rgba(0,0,0,.6);
  --overlay-strong:rgba(0,0,0,.85);

}

.lesson-video,
.lesson-steps,
.lesson-card,
.lessons-list-panel,
.loader-card {
  background: var(--surface);
}

:root {

  --nav-bg: rgba(255,255,255,0.85);
  --nav-text: #8f95a3;
  --nav-text-active: #5c5166;
  --nav-shadow: 0 4px 18px rgba(0,0,0,0.05);

}

[data-theme="dark"] {

  --nav-bg: rgba(28,29,31,0.85);
  --nav-text: #9ca3af;
  --nav-text-active: #c4b5fd;
  --nav-shadow: 0 4px 18px rgba(0,0,0,0.6);

}

.marketing-lesson-image {

  width: 100%;
  aspect-ratio: 1 / 1;

  border-radius: 14px;
  overflow: hidden;

  background: var(--surface);

}

.marketing-lesson-image img {

  width: 100%;
  height: 100%;
  object-fit: cover;

}

/* HERO CARD */

.premium-hero {

  background: linear-gradient(
    180deg,
    #ece7f2,
    #e3ddea
  );

  color: #111;

}


/* ===== DARK ===== */

[data-theme="dark"] .premium-hero {

  background: linear-gradient(
    180deg,
    #1c1d21,
    #141518
  );

  color: #fff;

  box-shadow:
    0 10px 30px rgba(0,0,0,.6),
    inset 0 1px 0 rgba(255,255,255,.05);

}

[data-theme="dark"] .hero-subtitle {
  color: #cfcfd4;
}

[data-theme="dark"] .lesson-title {
  color: #ffffff;
}


[data-theme="dark"] .big-cta {

  background: linear-gradient(
    135deg,
    #5b6cff,
    #4a5de0
  );

  color: #fff;

}

[data-theme="dark"] .big-cta {

  background: linear-gradient(
    135deg,
    #5b6cff,
    #4a5de0
  );

  color: #fff;

}

/* ===============================
   PREMIUM HERO GLASS
================================ */

.premium-hero {

  border-radius: 26px;
  padding: 28px 22px;

  background: linear-gradient(
    180deg,
    rgba(255,255,255,0.7),
    rgba(255,255,255,0.4)
  );

  backdrop-filter: blur(12px);

  box-shadow:
    0 10px 30px rgba(0,0,0,0.08),
    inset 0 1px 0 rgba(255,255,255,0.6);

  color: #111;

}


/* ===============================
   DARK PREMIUM
================================ */

[data-theme="dark"] .premium-hero {

  background: linear-gradient(
    180deg,
    rgba(30,31,35,0.9),
    rgba(18,19,22,0.85)
  );

  backdrop-filter: blur(14px);

  box-shadow:
    0 12px 40px rgba(0,0,0,0.6),
    inset 0 1px 0 rgba(255,255,255,0.05);

  color: #fff;

}

.big-cta {

  border-radius: 14px;

  background: linear-gradient(
    135deg,
    #6a7cff,
    #4f63e6
  );

  color: #fff;

  box-shadow:
    0 6px 18px rgba(80,90,255,.4);

  transition: .15s;
}

.big-cta:active {
  transform: scale(.97);
}


[data-theme="dark"] .big-cta {

  background: linear-gradient(
    135deg,
    #5a6bff,
    #3f52d9
  );

}

/* ===============================
   HERO — LIGHT
================================ */

.lesson-hero.premium-hero {

  border-radius: 26px;
  padding: 28px 22px;

  background: linear-gradient(
    180deg,
    #ffffff,
    #f3eef8
  );

  box-shadow:
    0 10px 30px rgba(0,0,0,0.08);

  color: #111;

}


/* ===============================
   HERO — DARK
================================ */

[data-theme="dark"] .lesson-hero.premium-hero {

  background: linear-gradient(
    180deg,
    #1e1f23,
    #141519
  );

  box-shadow:
    0 12px 40px rgba(0,0,0,0.6);

  color: #ffffff;

}

[data-theme="dark"] .lesson-hero .lesson-title {
  color: #ffffff;
}

[data-theme="dark"] .lesson-hero .hero-subtitle {
  color: #aeb3bd;
}

.recipes-subtitle {
  text-align: center;
  color: var(--text-muted);
  margin-top: 6px;
}

[data-theme="dark"] .recipes-subtitle {
  color: #b5b8c5;
}

