:root {
  --bg: #0b0f17;
  --bg-elev: #141a26;
  --bg-card: #161d2b;
  --border: #243049;
  --text: #e8edf6;
  --text-dim: #8d9ab5;
  --accent: #4f8cff;
  --accent-2: #34d399;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px env(safe-area-inset-bottom);
  min-height: 100vh;
  min-height: 100dvh;            /* avoids jump when mobile browser bars hide */
  overflow-x: hidden;            /* belt-and-suspenders against side-scroll */
  -webkit-tap-highlight-color: transparent;
}

/* Snappier taps on mobile: no 300ms delay, no double-tap zoom on controls. */
.card, .chip, .get-btn, .ghost-btn, .install-btn, .sheet-close, .footer a {
  touch-action: manipulation;
}

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: linear-gradient(180deg, rgba(11,15,23,0.98) 70%, rgba(11,15,23,0.0));
  padding-top: env(safe-area-inset-top);
  backdrop-filter: blur(10px);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0 10px;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo { border-radius: 10px; }
.brand-text h1 { font-size: 20px; margin: 0; letter-spacing: -0.02em; }
.brand-sub { margin: 2px 0 0; font-size: 12px; color: var(--text-dim); }

.ghost-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
}
.ghost-btn:active { transform: scale(0.97); }

.search-wrap { padding-bottom: 10px; }
#search {
  width: 100%;
  padding: 12px 16px;
  font-size: 16px;
  color: var(--text);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 999px;
  outline: none;
}
#search:focus { border-color: var(--accent); }

.categories {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 12px;
  scrollbar-width: none;
}
.categories::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  padding: 10px 16px;            /* bigger tap target (~40px tall) */
  border-radius: 999px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Grid */
.grid {
  display: grid;
  /* minmax(0, 1fr) lets the column shrink below its content so cards never
     overflow narrow screens (the no-wrap tagline was forcing them wider). */
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  padding: 4px 0 24px;
}

.card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  min-width: 0;                  /* allow the card to shrink within its track */
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.card:active { transform: scale(0.985); border-color: var(--accent); }

.card-icon {
  width: 60px; height: 60px;
  border-radius: 14px;
  flex: 0 0 auto;
  object-fit: cover;
  background: var(--bg-elev);
}

.card-body { flex: 1 1 auto; min-width: 0; }
.card-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;           /* long app names truncate instead of pushing GET off */
}
.card-tag {
  margin: 3px 0 0;
  font-size: 13px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-meta { margin: 6px 0 0; font-size: 11px; color: var(--text-dim); }

.get-btn {
  flex: 0 0 auto;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 10px 20px;            /* bigger, easier-to-hit tap target */
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.get-btn:active { transform: scale(0.95); }

/* Empty state */
.empty { text-align: center; padding: 60px 20px; color: var(--text-dim); }
.empty-art { font-size: 54px; }
.empty h2 { color: var(--text); margin: 12px 0 6px; }
.empty code {
  display: inline-block;
  margin-top: 14px;
  background: var(--bg-elev);
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 13px;
}
.empty code[hidden] { display: none; }

.footer {
  text-align: center;
  padding: 24px 0 40px;
  color: var(--text-dim);
  font-size: 12px;
}
.footer a { color: var(--accent); text-decoration: none; }

/* Sheet / modal */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
/* The hidden attribute must win over the display:flex above, otherwise the
   modals show on load and can never be dismissed. */
.sheet[hidden] { display: none; }
.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
  cursor: pointer; /* iOS Safari only fires tap/click on "clickable" elements */
}
.sheet-card {
  position: relative;
  width: 100%;
  max-width: 720px;
  background: var(--bg-elev);
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  border: 1px solid var(--border);
  padding: 22px 20px calc(28px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow);
  animation: slideUp 0.22s ease;
  max-height: 88vh;
  max-height: 88dvh;             /* dynamic vh so the sheet isn't clipped by browser bars */
  overflow-y: auto;
  overscroll-behavior: contain;  /* scrolling the sheet won't scroll the page behind it */
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.sheet-close {
  position: absolute;
  top: 14px; right: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  width: 40px; height: 40px;     /* larger, comfortable tap target */
  border-radius: 50%;
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
}

.sheet-head { display: flex; gap: 16px; align-items: center; }
.sheet-icon { width: 76px; height: 76px; border-radius: 18px; background: var(--bg-card); }
.sheet-head h2 { margin: 0; font-size: 22px; }
.sheet-meta { margin: 4px 0 0; color: var(--text-dim); font-size: 13px; }
.sheet-desc { margin: 18px 0; color: var(--text); line-height: 1.55; white-space: pre-wrap; }

.sheet-shots { display: flex; gap: 10px; overflow-x: auto; margin-bottom: 18px; }
.sheet-shots img { height: 320px; border-radius: 14px; border: 1px solid var(--border); }
.sheet-shots:empty { display: none; }

.install-btn {
  display: block;
  text-align: center;
  background: var(--accent-2);
  color: #06231a;
  font-weight: 700;
  font-size: 17px;
  padding: 15px;
  border-radius: 14px;
  text-decoration: none;
}
.install-btn:active { transform: scale(0.98); }

.sideload-note {
  margin: 14px 0 0;
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
}

.help-list { line-height: 1.7; color: var(--text); padding-left: 20px; }
.help-list li { margin-bottom: 6px; }
