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

:root {
  --bg:          #0f0f13;
  --surface:     #1a1a24;
  --surface2:    #22222e;
  --border:      #2e2e40;
  --accent:      #6c63ff;
  --accent-soft: #6c63ff22;
  --accent2:     #ff6584;
  --text:        #e8e8f0;
  --text-muted:  #8888a8;
  --radius:      14px;
  --radius-sm:   8px;
  --shadow:      0 4px 24px rgba(108,99,255,.15);
  --transition:  .22s cubic-bezier(.4,0,.2,1);
}

html { height: 100%; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 40px;
  /* Telegram theme integration */
  background-color: var(--tg-theme-bg-color, var(--bg));
  color: var(--tg-theme-text-color, var(--text));
}

/* ── Header ── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: linear-gradient(135deg, #13131e 0%, #1a1a28 100%);
  border-bottom: 1px solid var(--border);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.header-content {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.header-icon {
  font-size: 28px;
  line-height: 1;
  flex-shrink: 0;
}

.app-header h1 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Back Button ── */
.back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  cursor: pointer;
  color: var(--text);
  transition: background var(--transition), transform var(--transition);
}
.back-btn:active { transform: scale(.92); background: var(--border); }

/* ── Breadcrumb ── */
.breadcrumb {
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.crumb {
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition);
  white-space: nowrap;
}
.crumb:hover { color: var(--accent); }
.crumb.current { color: var(--text); font-weight: 600; cursor: default; }

.crumb-sep {
  font-size: 11px;
  color: var(--border);
}

/* ── Loading ── */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 80px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Content grid ── */
.content {
  padding: 16px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

/* ── Card ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: background var(--transition), border-color var(--transition),
              transform var(--transition), box-shadow var(--transition);
  animation: fadeUp .3s ease both;
}
.card:hover {
  background: var(--surface2);
  border-color: var(--accent);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.card:active { transform: scale(.97); }

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

/* stagger delay for children */
.card:nth-child(1)  { animation-delay: .03s; }
.card:nth-child(2)  { animation-delay: .06s; }
.card:nth-child(3)  { animation-delay: .09s; }
.card:nth-child(4)  { animation-delay: .12s; }
.card:nth-child(5)  { animation-delay: .15s; }
.card:nth-child(6)  { animation-delay: .18s; }
.card:nth-child(7)  { animation-delay: .21s; }
.card:nth-child(8)  { animation-delay: .24s; }
.card:nth-child(9)  { animation-delay: .27s; }
.card:nth-child(10) { animation-delay: .30s; }

.card-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  transition: background var(--transition);
}
.card:hover .card-icon { background: var(--accent); }

.card-label {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  flex: 1;
  line-height: 1.35;
}

.card-arrow {
  color: var(--text-muted);
  font-size: 18px;
  flex-shrink: 0;
  transition: color var(--transition), transform var(--transition);
}
.card:hover .card-arrow { color: var(--accent); transform: translateX(3px); }

/* ── Media Card (for exercises with sub-exercises) ── */
.media-card {
  background: linear-gradient(135deg, #1e1e2e 0%, #252535 100%);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  animation: fadeUp .3s ease both;
}
.media-card:hover  { transform: translateY(-3px); box-shadow: 0 8px 32px rgba(108,99,255,.25); }
.media-card:active { transform: scale(.97); }

.media-card-icon {
  font-size: 40px;
}

.media-card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
}

.media-card-badge {
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 20px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  animation: fadeUp .3s ease both;
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state p { font-size: 15px; line-height: 1.6; }

/* ── Media Overlay ── */
.media-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.88);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(255,255,255,.12);
  border: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}
.close-btn:hover { background: rgba(255,255,255,.22); }

.media-wrapper {
  max-width: min(92vw, 640px);
  max-height: 82vh;
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: popIn .25s cubic-bezier(.34,1.56,.64,1);
}
@keyframes popIn {
  from { transform: scale(.85); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.media-wrapper img,
.media-wrapper video {
  max-width: 100%;
  max-height: 82vh;
  border-radius: var(--radius);
  object-fit: contain;
}

.media-error {
  color: var(--text-muted);
  font-size: 15px;
  padding: 32px;
  text-align: center;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
