:root {
  color-scheme: dark;
  --bg: #0e0f11;
  --panel: #141518;
  --panel-2: #191b1f;
  --line: #282b31;
  --text: #f4f5f7;
  --muted: #969ba6;
  --soft: #c7cad1;
  --accent: #ffd84d;
  --accent-2: #ff9f1c;
  --accent-text: #160f00;
  --danger: #ff6b6b;
  --ok: #58d68d;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 72% 3%, rgba(255, 216, 77, 0.18), transparent 25rem),
    radial-gradient(circle at 20% 18%, rgba(255, 159, 28, 0.1), transparent 18rem),
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 28rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.light {
  color-scheme: light;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --panel-2: #eef0f4;
  --line: #d9dde5;
  --text: #111318;
  --muted: #626977;
  --soft: #333843;
  --accent: #101114;
  --accent-2: #c08a00;
  --accent-text: #ffffff;
  --shadow: 0 24px 80px rgba(22, 27, 34, 0.12);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea,
select {
  font: inherit;
}

button,
select,
label.file-btn {
  cursor: pointer;
}

.shell {
  width: min(1100px, calc(100% - 32px));
  margin: 0 auto;
}

.topbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  gap: 18px;
}

.brand,
.nav,
.hero-actions,
.admin-actions,
.form-actions {
  display: flex;
  align-items: center;
}

.brand {
  gap: 10px;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-mark {
  width: 38px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 900;
  font-size: 12px;
  box-shadow: inset -8px 0 0 rgba(255, 159, 28, 0.28), 0 0 30px rgba(255, 216, 77, 0.26);
}

.brand-mark img {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
}

.nav {
  gap: 24px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.nav a:hover {
  color: var(--text);
}

.ghost-btn,
.icon-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel);
  color: var(--text);
}

.hero,
.admin-hero {
  text-align: center;
  padding: 76px 0 42px;
}

.hero-logo-frame {
  position: relative;
  width: 132px;
  height: 132px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 18px;
  border-radius: 50%;
  border: 1px solid rgba(255, 216, 77, 0.38);
  background: radial-gradient(circle at 50% 38%, rgba(255, 216, 77, 0.16), rgba(255, 255, 255, 0.03) 58%, rgba(0, 0, 0, 0.12));
  box-shadow: 0 0 40px rgba(255, 216, 77, 0.25);
  overflow: hidden;
  isolation: isolate;
}

.hero-logo-frame::before {
  content: "";
  position: absolute;
  inset: -18%;
  z-index: -1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 216, 77, 0.3), transparent 62%);
  filter: blur(16px);
  animation: logoGlow 5.5s ease-in-out infinite;
}

.hero-logo-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  filter: drop-shadow(0 0 20px rgba(255, 216, 77, 0.24));
}

.hero-brand-fallback {
  display: none;
  align-items: center;
  gap: 14px;
  color: var(--text);
  font-size: clamp(24px, 5vw, 54px);
  font-weight: 900;
  letter-spacing: 0;
}

.logo-missing .hero-brand-fallback {
  display: inline-flex;
}

.hero-moon {
  width: clamp(52px, 10vw, 86px);
  height: clamp(52px, 10vw, 86px);
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 32%, #ffffff 0 18%, transparent 19%),
    linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #07111f;
  font-size: clamp(16px, 3vw, 28px);
  font-weight: 950;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.16),
    0 0 44px rgba(255, 216, 77, 0.34);
}

@keyframes logoGlow {

  0%,
  100% {
    opacity: 0.58;
    transform: scale(0.98);
  }

  50% {
    opacity: 1;
    transform: scale(1.04);
  }
}

.eyebrow,
.kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 12px;
  font-weight: 800;
}

.eyebrow {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.03);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.hero h1,
.admin-hero h1 {
  width: min(760px, 100%);
  margin: 18px auto 14px;
  font-size: clamp(38px, 7vw, 72px);
  line-height: 0.98;
  letter-spacing: 0;
}

.admin-hero h1 {
  font-size: clamp(34px, 6vw, 58px);
}

.hero p,
.admin-hero p {
  width: min(620px, 100%);
  margin: 0 auto 26px;
  color: var(--muted);
  line-height: 1.6;
}

.hero-actions {
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.primary-btn,
.secondary-btn {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 0 18px;
  font-weight: 750;
  transition: transform 220ms ease, border-color 220ms ease, background 220ms ease, box-shadow 220ms ease, opacity 220ms ease;
}

.primary-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-text);
  border-color: transparent;
  box-shadow: 0 0 30px rgba(255, 216, 77, 0.22);
}

.secondary-btn {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
}

.primary-btn:hover,
.secondary-btn:hover {
  transform: translateY(-1px);
  border-color: var(--soft);
}

.primary-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.compact {
  min-height: 38px;
  padding: 0 14px;
  font-size: 13px;
}

.full {
  width: 100%;
}

.stats-grid {
  width: min(560px, 100%);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 34px auto 0;
}

.stats-grid div {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 216, 77, 0.08), rgba(255, 255, 255, 0.02));
}

.stats-grid strong {
  display: block;
  font-size: 26px;
  color: var(--accent);
}

.stats-grid span {
  color: var(--muted);
  font-size: 13px;
}

.toolbar-section,
.admin-panel {
  padding: 36px 0;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.section-heading h2 {
  margin: 8px 0 0;
  font-size: clamp(26px, 4vw, 42px);
  letter-spacing: 0;
}

.pill {
  flex: 0 0 auto;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--soft);
  background: var(--panel);
  font-size: 13px;
  font-weight: 750;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr 190px;
  gap: 12px;
  margin-bottom: 16px;
}

.search-box,
select,
input,
textarea {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
}

.search-box {
  min-height: 50px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: 12px;
  padding: 0 16px;
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
}

select,
input,
textarea {
  width: 100%;
  border-radius: 10px;
  outline: none;
}

select {
  padding: 0 14px;
}

.category-tabs {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow-x: auto;
  padding: 0 0 18px;
}

.tab-btn {
  flex: 0 0 auto;
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  background: transparent;
  color: var(--muted);
  font-weight: 750;
}

.tab-btn.active {
  background: var(--accent);
  color: var(--accent-text);
}

.apk-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.apk-card,
.apk-form,
.admin-list,
.download-modal {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(20, 21, 24, 0.74);
  box-shadow: var(--shadow);
}

body.light .apk-card,
body.light .apk-form,
body.light .admin-list,
body.light .download-modal {
  background: rgba(255, 255, 255, 0.88);
}

.apk-card {
  padding: 18px;
  min-height: 250px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: transform 220ms ease, border-color 220ms ease, box-shadow 220ms ease;
}

.apk-card:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 216, 77, 0.46);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.38), 0 0 40px rgba(255, 216, 77, 0.13);
}

.card-top,
.admin-item-top,
.modal-head,
.list-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.app-id {
  display: flex;
  gap: 12px;
  min-width: 0;
}

.app-icon {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  font-weight: 900;
  overflow: hidden;
}

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

.app-id h3 {
  margin: 1px 0 5px;
  font-size: 16px;
}

.meta-line,
.card-desc,
.admin-item p,
.empty-state,
.download-modal p {
  color: var(--muted);
  line-height: 1.55;
}

.meta-line {
  font-size: 13px;
}

.featured-badge {
  height: 22px;
  padding: 0 9px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--soft);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.card-desc {
  margin: 0;
  font-size: 14px;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
}

.tag {
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.card-footer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  border-top: 1px solid var(--line);
  padding-top: 13px;
}

.tiny-meta {
  color: var(--muted);
  font-size: 12px;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 16px;
  align-items: start;
}

.apk-form,
.admin-list {
  padding: 18px;
}

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

.form-grid label {
  display: grid;
  gap: 7px;
  color: var(--soft);
  font-size: 13px;
  font-weight: 750;
}

.form-grid .wide {
  grid-column: 1 / -1;
}

.form-grid input,
.form-grid textarea {
  padding: 12px;
  resize: vertical;
}

.check-row {
  display: flex !important;
  grid-auto-flow: column;
  align-items: center;
  justify-content: start;
  gap: 10px;
}

.check-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.form-actions,
.admin-actions {
  gap: 10px;
  flex-wrap: wrap;
}

.form-actions {
  margin-top: 16px;
}

.file-btn input {
  display: none;
}

.admin-list {
  max-height: 780px;
  overflow: auto;
}

.list-head {
  align-items: center;
  margin-bottom: 12px;
}

.list-head span {
  color: var(--muted);
  font-size: 13px;
}

.admin-item {
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.admin-item:first-child {
  border-top: 0;
}

.admin-item h3 {
  margin: 0 0 4px;
  font-size: 15px;
}

.admin-item p {
  margin: 0 0 12px;
  font-size: 13px;
}

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

.mini-btn {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--text);
  padding: 0 12px;
  font-weight: 750;
}

.mini-btn.danger {
  color: var(--danger);
}

.download-modal {
  width: min(460px, calc(100% - 28px));
  color: var(--text);
  padding: 20px;
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  transition: opacity 220ms ease, transform 220ms ease, overlay 220ms ease allow-discrete, display 220ms ease allow-discrete;
}

.download-modal[open] {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.download-modal::backdrop {
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(6px);
}

.download-modal h3 {
  margin: 8px 0 0;
  font-size: 24px;
}

.telegram-gateway-logo {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  margin: 0 auto 14px;
  border: 1px solid rgba(255, 216, 77, 0.38);
  border-radius: 50%;
  color: #ffd84d;
  background: radial-gradient(circle at 50% 40%, rgba(255, 216, 77, 0.18), rgba(255, 255, 255, 0.04));
  box-shadow: 0 0 34px rgba(255, 216, 77, 0.24);
}

.telegram-gateway-logo [data-icon] {
  width: 28px;
  height: 28px;
}

.gateway-steps {
  display: grid;
  gap: 10px;
  margin: 18px 0 14px;
}

.gateway-step {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  overflow: hidden;
  transition: border-color 260ms ease, background 260ms ease, box-shadow 260ms ease, transform 260ms ease;
}

.gateway-step::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  background: linear-gradient(110deg, transparent, rgba(255, 216, 77, 0.22), transparent);
  transform: translateX(-100%);
}

.gateway-step.verifying::after {
  opacity: 1;
  animation: verifySweep 900ms ease forwards;
}

.gateway-step strong,
.gateway-step span {
  display: block;
}

.gateway-step span:not(.step-number) {
  color: var(--muted);
  font-size: 14px;
}

.gateway-step.done {
  border-color: rgba(255, 216, 77, 0.74);
  background: linear-gradient(135deg, rgba(255, 216, 77, 0.14), rgba(88, 214, 141, 0.06));
  box-shadow: 0 0 32px rgba(255, 216, 77, 0.17);
}

.step-number {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 900;
}

.verify-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.verify-btn.verified {
  color: var(--ok);
  border-color: rgba(88, 214, 141, 0.42);
}

#continueDownloadBtn.gateway-ready {
  animation: readyPulse 2.4s ease-in-out infinite;
}

@keyframes verifySweep {
  from {
    transform: translateX(-100%);
  }

  to {
    transform: translateX(100%);
  }
}

@keyframes readyPulse {

  0%,
  100% {
    box-shadow: 0 0 26px rgba(255, 216, 77, 0.22);
  }

  50% {
    box-shadow: 0 0 48px rgba(255, 216, 77, 0.38);
  }
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(360px, calc(100% - 36px));
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

[data-icon] {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 860px) {
  .topbar {
    flex-wrap: wrap;
    padding: 14px 0;
  }

  .nav {
    order: 3;
    width: 100%;
    justify-content: center;
    gap: 16px;
  }

  .search-row,
  .admin-layout,
  .apk-grid {
    grid-template-columns: 1fr;
  }

  .section-heading {
    align-items: start;
    flex-direction: column;
  }
}

@media (max-width: 560px) {
  .shell {
    width: min(100% - 22px, 1100px);
  }

  .hero-logo-frame {
    width: 104px;
    height: 104px;
  }

  .hero,
  .admin-hero {
    padding-top: 46px;
  }

  .stats-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .gateway-step,
  .card-footer {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .form-grid .wide {
    grid-column: auto;
  }
}
