/* root (theme) */
:root {
  --bg: #000;
  --card: rgba(28,28,30,.72);
  --accent: #0a84ff;
  --text: #f5f5f7;
  --subtle: #8e8e93;
  --radius: 16px;
  --shadow: 0 12px 30px rgba(0,0,0,.45);
  --ease: cubic-bezier(.2,.8,.2,1);
}

/* global fix */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  width: 100%;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  margin: 0;
  padding: 0;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(900px 360px at 20% -10%, rgba(10,132,255,.14), transparent 55%),
    radial-gradient(800px 340px at 90% 0%, rgba(255,255,255,.06), transparent 60%);
  background-repeat: no-repeat;
}

/* header */
header {
  position: sticky;
  top: 0;
  z-index: 30;
  padding: 30px 20px 22px;
  text-align: center;
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  background: linear-gradient(
    to bottom,
    rgba(0,0,0,.75),
    rgba(0,0,0,.55),
    rgba(0,0,0,.25)
  );
  transition: transform .45s var(--ease);
}

#sortSelect {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  height: calc(100% - 12px);
  border-radius: 12px;
  padding: 0 10px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--text);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s var(--ease);
}

#sortSelect.show {
  opacity: 1;
  transform: translateY(-50%);
  pointer-events: auto;
}

#backBtn {
  display: none;
}

.loading-line {
  text-align: center;
  padding: 14px;
}

header.unpin {
  transform: translateY(-120%);
}

h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
}

/* container */
#container {
  max-width: 980px;
  margin: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* search bar */
.searchWrap {
  position: relative;
  flex: 1;
}

#searchBar {
  width: 100%;
  display: none;
  gap: 10px;
  margin-bottom: 10px;
  animation: fadeUp .35s var(--ease) both;
  position: relative;
}

#searchInput {
  width: 100%;
  flex: 1;
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.03);
  padding-right: 96px;
  color: var(--text);
  font-size: 16px;
  outline: none;
}

#searchInput:focus {
  border-color: var(--accent);
}

#searchBtn {
  padding: 10px 16px;
  border-radius: var(--radius);
  border: none;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

/* repo list */
.repo-card {
  display: flex;
  gap: 12px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px) saturate(180%);
  align-items: center;
  opacity: 0;
  transform: translateY(6px);
}

.repo-card.show {
  opacity: 1;
  transform: translateY(0);
  transition: opacity .3s ease, transform .3s ease;
}

.repo-card img {
  width: 60px;
  height: 60px;
  object-fit: contain;
  background: rgba(255,255,255,.04);
  border-radius: var(--radius);
  flex-shrink: 0;
}

.repo-info {
  flex: 1;
}

.repo-name {
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 6px;
}

.repo-desc {
  font-size: 14px;
  color: var(--subtle);
}

/* repo actions */
.repo-actions {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
}

.repo-actions button {
  padding: 6px 12px;
  font-size: 12px;
  min-height: 34px;
}

/* copy button */
.repo-actions .copyBtn {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,.12);
  color: var(--text);
}

/* remove button */
.repo-actions .removeBtn {
  background: rgba(255,69,58,.18);
  border: 1px solid rgba(255,69,58,.28);
  box-shadow: 0 0 0 1px rgba(255,69,58,.12) inset;
}

/* buttons */
button,
#importBtn,
#importModal button,
.card .download {
  appearance: none;
  border: none;
  border-radius: 999px;
  font-weight: 700;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(10,132,255,.22);
  transition:
    transform .22s var(--ease),
    box-shadow .22s var(--ease),
    filter .22s;
}

button:active,
.card .download:active {
  transform: scale(.94);
  box-shadow: 0 6px 14px rgba(10,132,255,.32);
}

#importBtn {
  min-height: 44px;
  padding: 10px 18px;
  font-size: 15px;
  z-index: 40;
}

/* apps grid */
#apps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-top: 10px;
  width: 100%;
  justify-content: start;
}

/* app card */
.card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px) saturate(180%);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .35s ease, transform .35s ease;
}

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

.card .icon {
  width: 72px;
  height: 72px;
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
}

.card .icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* spacing fix */
.card .title {
  font-weight: 700;
  font-size: 14px;
  text-align: center;
  margin-bottom: 10px;
}

.meta {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 8px;
}

.card .repo-meta {
  font-size: 12px;
  color: var(--subtle);
  font-weight: 600;
  text-align: center;
  margin-bottom: 6px;
}

.card .subtitle {
  font-size: 12px;
  color: var(--subtle);
  text-align: center;
  margin-bottom: 10px;
}

/* version / size */
.meta .version,
.meta .size {
  font-size: 11px;
  padding: 3px 8px;
  white-space: nowrap;
  border-radius: 999px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}

/* download */
.card .download {
  margin-top: auto;
  font-size: 13px;
  padding: 9px;
  text-align: center;
  border-radius: var(--radius);
  text-decoration: none;
}

/* back button */
#backBtn {
  align-items: center;
  justify-content: center;
  width: auto;
  padding: 8px 14px;
  font-size: 13px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: 0 6px 14px rgba(255,255,255,.08);
}

/* footer */
.footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-top: 40px;
  padding-bottom: 30px;
  font-size: 14px;
  color: var(--subtle);
}

.github-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  opacity: 0.85;
  transition: opacity .2s var(--ease), transform .2s var(--ease);
}

.github-link svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* animations */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* import modal animation */
#importModal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s var(--ease);
}

#importModal.show {
  opacity: 1;
  pointer-events: all;
}

#importModal .box {
  background: var(--card);
  padding: 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  gap: 10px;
  width: min(90%, 360px);
  transform: scale(0.95);
  transition: transform 0.25s var(--ease);
}

#importModal.show .box {
  transform: scale(1);
}

/* mobile */
@media (max-width: 640px) {
  #container { padding: 12px; }

  #apps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .repo-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .repo-actions {
    width: 100%;
    margin-top: 8px;
    justify-content: space-between;
  }
}
