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

:root {
  --bg-start: #0f2545;
  --bg-end:   #3a7cff;
  --accent:   #60a5fa;
  --accent-dark: #2563eb;
  --card-bg:  rgba(30, 58, 138, 0.45);
  --text:     #f0f9ff;
  --text-sec: #bfdbfe;
  --header-bg: rgba(10, 20, 45, 0.92);
  --border:   rgba(96, 165, 250, 0.22);
  --radius:   20px;
  --blur:     blur(16px);
  --shadow:   0 10px 30px rgba(0, 0, 0, 0.35);
  --transition: all 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}

body {
  font-family: "SF Pro Display", -apple-system, BlinkMacSystemFont, sans-serif;
  background: linear-gradient(to bottom, var(--bg-start), var(--bg-end));
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-bottom: calc(80px + env(safe-area-inset-bottom));
  position: relative;
  overflow-x: hidden;

  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

/* Слой звёзд 1 — крупные и заметные */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -2;

  background:
    radial-gradient(2.0px 2.0px at 10% 15%, #fff 45%, transparent 70%),
    radial-gradient(1.8px 1.8px at 30% 40%, #eee 50%, transparent 70%),
    radial-gradient(2.4px 2.4px at 50% 60%, #fff 40%, transparent 70%),
    radial-gradient(1.6px 1.6px at 70% 25%, #ddd 55%, transparent 70%),
    radial-gradient(2.2px 2.2px at 85% 75%, #eee 45%, transparent 70%),
    radial-gradient(1.9px 1.9px at 5% 90%, #fff 50%, transparent 70%),
    radial-gradient(2.1px 2.1px at 40% 5%, #eee 45%, transparent 70%),
    radial-gradient(1.7px 1.7px at 60% 85%, #fff 45%, transparent 70%);
  background-repeat: repeat;
  background-size: 280px 280px;
  opacity: 0.72;

  animation: drift-bg 180s linear infinite;
  will-change: background-position;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

/* Слой звёзд 2 — тоже крупные */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -2;

  background:
    radial-gradient(1.5px 1.5px at 20% 30%, #fff 55%, transparent 70%),
    radial-gradient(1.7px 1.7px at 40% 70%, #eee 50%, transparent 70%),
    radial-gradient(1.3px 1.3px at 60% 10%, #ddd 55%, transparent 70%),
    radial-gradient(1.8px 1.8px at 80% 80%, #fff 50%, transparent 70%),
    radial-gradient(1.4px 1.4px at 95% 5%, #eee 45%, transparent 70%),
    radial-gradient(1.6px 1.6px at 15% 95%, #fff 50%, transparent 70%);
  background-repeat: repeat;
  background-size: 200px 200px;
  opacity: 0.58;

  animation: drift-bg 240s linear infinite reverse;
  will-change: background-position;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

@keyframes drift-bg {
  from { background-position: 0 0; }
  to   { background-position: -360px -360px; }
}

/* Мерцание отдельных звёзд */
.stars-twinkle {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;

  box-shadow:
    80px  120px 1.2px #fff,
   140px  300px 1.5px #eee,
   220px   60px 1.0px #ddd,
   310px  190px 1.3px #fff,
   390px   80px 1.4px #eee,
   480px  340px 1.1px #fff,
   590px  130px 0.9px #ddd,
   680px  270px 1.6px #eee,
   810px   50px 0.8px #fff,
   890px  390px 1.3px #ddd,
   150px  220px 1.5px #eee,
   340px  410px 1.0px #fff,
   520px  180px 1.2px #eee,
   670px  450px 0.9px #fff;
  opacity: 0.78;
  animation: twinkle 9s ease-in-out infinite alternate;
  will-change: opacity, transform;
}

@keyframes twinkle {
  0%, 100% { opacity: 0.50; transform: scale(1); }
  30%      { opacity: 0.95; transform: scale(1.012); }
  60%      { opacity: 0.70; transform: scale(1.004); }
  90%      { opacity: 0.88; transform: scale(1.008); }
}

/* Основной контент */
.main-content {
  position: relative;
  z-index: 1;
  padding-top: calc(72px + env(safe-area-inset-top));
  padding-left: 16px;
  padding-right: 16px;
  padding-bottom: 20px;
  margin: 0 auto;
  max-width: 480px;
}

/* Тёмная шапка */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: calc(56px + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
}

.header-content {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: #e0f2fe;
}

/* Поиск */
.search-container {
  margin-bottom: 20px;
  padding: 8px 0;
}

.search-input {
  width: 100%;
  padding: 12px 16px;
  font-size: 17px;
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(96, 165, 250, 0.35);
  border-radius: 14px;
  color: var(--text);
  outline: none;
  transition: var(--transition);
  backdrop-filter: blur(10px);
}

.search-input::placeholder {
  color: var(--text-sec);
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.25);
  background: rgba(255, 255, 255, 0.15);
}

/* Список карточек */
.app-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 0;
}

.loading {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-sec);
  font-size: 17px;
}

.app-card.minimal {
  background: var(--card-bg);
  backdrop-filter: var(--blur);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: var(--shadow);
  transition: var(--transition);
  border: 1px solid var(--border);
}

.app-card.minimal:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.45);
}

.app-header {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
}

.app-icon {
  width: 60px;
  height: 60px;
  border-radius: 16px;
  object-fit: cover;
  background: #334155;
}

.app-title {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.3;
}

/* Кнопка "Открыть" — светлее, без сильного свечения */
.btn-open {
  background: rgba(96, 165, 250, 0.45);
  color: #ffffff;
  border: 1px solid rgba(96, 165, 250, 0.60);
  padding: 10px 20px;
  border-radius: 14px;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  min-width: 100px;
  text-align: center;
  backdrop-filter: blur(10px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.btn-open:hover {
  background: rgba(96, 165, 250, 0.65);
  border-color: rgba(96, 165, 250, 0.85);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(96, 165, 250, 0.25);
}

.btn-open:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Модальное окно — ярче */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.34s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.34s step-end;
  will-change: opacity, visibility;
}

.modal.show {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.34s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.34s step-start;
}

.modal-content {
  background: rgba(20, 35, 70, 0.88);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-radius: 28px;
  padding: 28px;
  max-width: 420px;
  width: 100%;
  border: 1px solid rgba(96, 165, 250, 0.28);
  box-shadow: 
    0 30px 80px rgba(0, 0, 0, 0.55),
    inset 0 0 40px rgba(96, 165, 250, 0.12);
  transform: scale(0.92) translateY(24px);
  opacity: 0;
  transition: all 0.34s cubic-bezier(0.34, 1.56, 0.64, 1.2);
  will-change: transform, opacity;
}

.modal.show .modal-content {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.modal.closing .modal-content {
  transform: scale(0.94) translateY(40px);
  opacity: 0;
  transition-duration: 0.28s;
  transition-timing-function: cubic-bezier(0.4, 0, 0.6, 1);
}

.close-modal {
  position: absolute;
  top: 16px;
  right: 20px;
  font-size: 36px;
  color: #bfdbfe;
  cursor: pointer;
  line-height: 1;
  transition: color 0.2s ease;
}

.close-modal:hover {
  color: #ffffff;
}

.modal-top {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 24px;
}

.modal-icon {
  width: 88px;
  height: 88px;
  border-radius: 22px;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.modal-title-section {
  flex: 1;
}

.modal h2 {
  font-size: 26px;
  font-weight: 700;
  margin: 0 0 10px 0;
  line-height: 1.2;
  color: #e0f2fe;
}

.meta-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 14px;
  color: #d1e8ff;
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.meta-label {
  color: #a5d0ff;
  font-weight: 500;
  min-width: 55px;
}

.meta-value {
  color: #ffffff;
  font-weight: 600;
}

.features-block {
  background: rgba(96, 165, 250, 0.15);
  backdrop-filter: blur(12px);
  border-radius: 14px;
  padding: 16px 20px;
  margin-bottom: 24px;
  border: 1px solid rgba(96, 165, 250, 0.30);
}

.features-block p {
  font-size: 15px;
  line-height: 1.6;
  color: #e6f2ff;
  margin: 0;
}

.features-block p:empty::before {
  content: "Нет дополнительной информации";
  color: #a5d0ff;
  font-style: italic;
}

.cert-warning {
  background: rgba(255, 193, 7, 0.12);
  backdrop-filter: blur(10px);
  border-radius: 14px;
  padding: 14px 18px;
  border: 1px solid rgba(255, 193, 7, 0.35);
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 28px;
}

.warning-icon {
  font-size: 22px;
  line-height: 1;
  color: #ffca28;
  flex-shrink: 0;
  margin-top: 2px;
}

.warning-text p {
  font-size: 14px;
  line-height: 1.5;
  color: #fff8e1;
  margin: 0;
}

.modal-buttons {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 24px;
}

#modalDownloadBtn,
.btn-buy-cert {
  width: 100%;
  padding: 15px;
  border-radius: 16px;
  font-weight: 600;
  font-size: 17px;
  text-align: center;
  text-decoration: none;
  transition: var(--transition);
}

#modalDownloadBtn {
  background: linear-gradient(135deg, #60a5fa, #3b82f6);
  color: #ffffff;
  box-shadow: 0 6px 20px rgba(96, 165, 250, 0.4);
}

#modalDownloadBtn:hover {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 10px 30px rgba(59, 130, 246, 0.5);
}

.btn-buy-cert {
  background: rgba(96, 165, 250, 0.20);
  color: #93c5fd;
  border: 1px solid rgba(96, 165, 250, 0.40);
}

.btn-buy-cert:hover {
  background: rgba(96, 165, 250, 0.35);
  transform: translateY(-2px);
  border-color: #93c5fd;
}

/* Нижняя навигация */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(60px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--header-bg);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 100;
}

.tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-sec);
  text-decoration: none;
  font-size: 10px;
  font-weight: 500;
  width: 25%;
  transition: var(--transition);
}

.tab-item.active {
  color: var(--accent);
}

.tab-item.active .tab-icon {
  filter: brightness(0) invert(1) sepia(1) saturate(5) hue-rotate(180deg);
  transform: scale(1.15);
}

.tab-item:hover .tab-icon {
  filter: brightness(0) invert(1) sepia(1) saturate(5) hue-rotate(180deg);
}

.tab-icon {
  width: 28px;
  height: 28px;
  margin-bottom: 4px;
  filter: brightness(0) invert(0.9);
  transition: var(--transition);
}

/* Адаптив */
@media (min-width: 768px) {
  .main-content {
    max-width: 720px;
    padding-left: 32px;
    padding-right: 32px;
  }
  .app-card.minimal {
    max-width: 500px;
    margin: 0 auto;
  }
}
