:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #eceef2;
  --text: #111418;
  --muted: #6b7280;
  --border: #e2e5ea;
  --accent: #2563eb;
  --accent-2: #7c3aed;
  --danger: #dc2626;
  --ok: #16a34a;
  --radius: 16px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-2: #2c2c2e;
    --text: #f5f5f7;
    --muted: #98989f;
    --border: #2c2c2e;
    --accent: #3b8bff;
    --accent-2: #9b6bff;
    --danger: #f05252;
    --ok: #31c46b;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.spacer { flex: 1; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--border);
}
.topbar .wrap { display: flex; align-items: center; gap: 10px; height: 56px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; letter-spacing: -.01em; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center;
}

/* ---------- Search ---------- */
.search { position: relative; display: block; margin: 16px 0 12px; }
.search input {
  width: 100%; height: 44px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); padding: 0 14px 0 40px; outline: none;
}
.search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input:focus, .input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}


.section-title {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  font-size: 20px; font-weight: 700; letter-spacing: -.01em; margin: 24px 0 6px;
}
.section-title small { font-size: 13px; color: var(--muted); font-weight: 500; }

/* ---------- Icons ---------- */
.icon {
  position: relative; flex: none; overflow: hidden;
  width: 64px; height: 64px; border-radius: 22%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; font-size: 26px;
  box-shadow: inset 0 0 0 1px rgba(127, 127, 127, .15);
}
.icon::before { content: attr(data-l); color: #fff; font-weight: 700; }
.icon img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.icon.sm { width: 48px; height: 48px; font-size: 20px; }
.icon.lg { width: 112px; height: 112px; font-size: 46px; }
@media (min-width: 640px) { .icon.lg { width: 136px; height: 136px; font-size: 56px; } }

/* ---------- List rows ---------- */
.list { display: grid; grid-template-columns: 1fr; column-gap: 28px; }
@media (min-width: 640px) { .list { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1000px) { .list { grid-template-columns: 1fr 1fr 1fr; } }
.row { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--border); min-width: 0; }
.row-info { flex: 1; min-width: 0; }
.row-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.get {
  flex: none; height: 30px; min-width: 72px; padding: 0 16px; border-radius: 999px;
  background: var(--surface-2); color: var(--accent); font-weight: 700; font-size: 14px;
  display: inline-grid; place-items: center;
}
.empty { text-align: center; color: var(--muted); padding: 48px 16px; grid-column: 1 / -1; }
.list.loading { opacity: .5; transition: opacity .15s; }

/* ---------- Pagination ---------- */
.pager { display: flex; justify-content: center; align-items: center; gap: 6px; flex-wrap: wrap; margin: 24px 0 8px; }
.pager button, .pager .gap {
  min-width: 38px; height: 38px; padding: 0 10px; border-radius: 10px;
  font-size: 14px; font-weight: 600; display: inline-grid; place-items: center;
}
.pager button { border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; }
.pager button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.pager button[aria-current="page"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.pager button:disabled { opacity: .4; cursor: default; }
.pager .gap { color: var(--muted); min-width: 20px; padding: 0; }

/* ---------- Featured carousel ---------- */
.carousel {
  display: grid; grid-auto-flow: column; grid-auto-columns: 86%; gap: 12px;
  overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none;
  margin: 0 -16px; padding: 4px 16px 6px; scroll-padding: 16px;
}
.carousel::-webkit-scrollbar { display: none; }
@media (min-width: 640px) { .carousel { grid-auto-columns: calc(50% - 6px); } }
@media (min-width: 1000px) { .carousel { grid-auto-columns: calc(33.333% - 8px); } }
.feature {
  scroll-snap-align: start; display: flex; gap: 14px; align-items: center;
  padding: 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border);
}
.feature .tag { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--accent); }
.feature .name { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feature .blurb {
  color: var(--muted); font-size: 13px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* ---------- Buttons & badges ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 18px; border-radius: 999px; border: 0; cursor: pointer;
  background: var(--accent); color: #fff; font-weight: 600; white-space: nowrap;
}
.btn.sm { height: 32px; padding: 0 14px; font-size: 14px; }
.btn.block { width: 100%; height: 46px; }
.btn.ghost { background: var(--surface-2); color: var(--text); }
.btn.danger { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.btn:disabled { opacity: .6; cursor: default; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 999px; border: 0; cursor: pointer;
  background: var(--surface-2); display: grid; place-items: center;
}
.badge {
  display: inline-block; vertical-align: middle; font-size: 11px; font-weight: 700; line-height: 1.6;
  padding: 0 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: .03em;
  background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent);
}
.badge.draft { background: var(--surface-2); color: var(--muted); }

/* ---------- Detail page ---------- */
.detail { max-width: 760px; margin: 0 auto; padding-bottom: 40px; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--accent); font-weight: 500; height: 48px; }
.hero { display: flex; gap: 16px; align-items: flex-start; padding: 4px 0 18px; }
.hero-info { min-width: 0; flex: 1; }
.hero h1 { font-size: 22px; line-height: 1.2; margin: 2px 0 4px; letter-spacing: -.02em; overflow-wrap: anywhere; }
.hero .dev { color: var(--muted); font-size: 14px; margin-bottom: 12px; }
@media (min-width: 640px) { .hero h1 { font-size: 30px; } }
.stats {
  display: grid; grid-template-columns: repeat(4, 1fr); text-align: center;
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 12px 0;
}
.stat { min-width: 0; padding: 0 4px; }
.stat + .stat { border-left: 1px solid var(--border); }
.stat .k { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.stat .v { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.desc { white-space: pre-line; overflow-wrap: anywhere; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.versions { display: grid; gap: 10px; }
.ver-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ver-head strong { font-size: 16px; }
.ver-meta { color: var(--muted); font-size: 13px; }
.ver-notes { margin: 8px 0 12px; white-space: pre-line; font-size: 14px; overflow-wrap: anywhere; }

/* ---------- Forms ---------- */
.field { display: grid; gap: 6px; margin-bottom: 14px; min-width: 0; }
.label { font-size: 13px; font-weight: 600; color: var(--muted); }
.input {
  width: 100%; height: 42px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); padding: 0 12px; outline: none;
}
textarea.input { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr; column-gap: 12px; }
@media (min-width: 560px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.checks { display: flex; gap: 20px; flex-wrap: wrap; margin-bottom: 14px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.error { color: var(--danger); font-size: 14px; min-height: 1.5em; margin: 0 0 8px; }
.icon-picker { display: flex; gap: 12px; align-items: center; }
.icon-picker .field { flex: 1; margin: 0; }

/* ---------- Admin ---------- */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; }
.login-card h1 { font-size: 22px; margin: 14px 0 4px; }
.stat-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 16px; }
@media (min-width: 640px) { .stat-cards { grid-template-columns: repeat(4, 1fr); } }
.stat-cards .card { padding: 12px 14px; }
.stat-cards .n { font-size: 24px; font-weight: 700; line-height: 1.2; }
.toolbar { display: flex; gap: 10px; align-items: center; margin: 16px 0 4px; }
.toolbar .search { flex: 1; margin: 0; }
.admin-list { display: grid; }
.row-actions { display: flex; gap: 6px; flex: none; }
@media (max-width: 479px) {
  .admin-list .row { flex-wrap: wrap; }
  .admin-list .row-actions { width: 100%; padding-left: 62px; }
}

dialog.sheet {
  border: 0; padding: 0; background: var(--bg); color: var(--text);
  width: 100%; max-width: 100%; height: 100%; max-height: 100%; margin: 0;
}
dialog.sheet::backdrop { background: rgba(0, 0, 0, .55); }
dialog.sheet form { display: flex; flex-direction: column; height: 100%; }
@media (min-width: 720px) {
  dialog.sheet { max-width: 680px; height: auto; max-height: 92dvh; margin: auto; border-radius: 20px; }
  dialog.sheet form { max-height: 92dvh; }
}
.sheet-head, .sheet-foot { display: flex; align-items: center; gap: 8px; padding: 12px 16px; background: var(--bg); }
.sheet-head { border-bottom: 1px solid var(--border); }
.sheet-head h2 { margin: 0; font-size: 18px; flex: 1; }
.sheet-foot { border-top: 1px solid var(--border); justify-content: flex-end; }
.sheet-body { flex: 1; overflow-y: auto; padding: 16px; }
.sheet-body h3 { font-size: 15px; margin: 8px 0 10px; display: flex; align-items: center; justify-content: space-between; }
.ver-edit { margin-bottom: 12px; }
.ver-edit .ver-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; font-weight: 600; }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-size: 14px; font-weight: 500;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 100; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--danger); color: #fff; }

.foot { color: var(--muted); font-size: 13px; padding: 32px 16px 40px; text-align: center; }


/* ---------- App cards (shelves + lists) ---------- */
.app-card {
  display: flex; align-items: center; gap: 14px; min-width: 0;
  padding: 8px 0;
}
.app-card > * { transition: opacity .15s; }
.app-card:hover > * { opacity: .85; }
.app-card:active > * { opacity: .6; }
.app-card .icon { width: 72px; height: 72px; border-radius: 20px; }
/* Hairline between items, starting under the text like the App Store (72px icon + 14px gap). */
.app-card { position: relative; }
.app-card::after { content: ""; position: absolute; left: 86px; right: 0; bottom: -2px; height: 1px; background: var(--border); }
.shelf-track > .app-card:nth-child(3n)::after,
.shelf-track > .app-card:last-child::after,
.list > .app-card:last-child::after { display: none; }
.card-name { font-weight: 700; font-size: 17px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-ver { color: var(--muted); font-weight: 600; font-size: 15px; line-height: 1.35; }
.card-sub { color: var(--muted); font-size: 14px; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chev { flex: none; color: var(--muted); }
.app-card .get { min-width: 68px; padding: 0 14px; background: color-mix(in srgb, var(--accent) 14%, transparent); }

.list:has(.app-card) { column-gap: 28px; row-gap: 4px; margin-top: 6px; }

/* ---------- Category shelves ---------- */
.shelf { margin-top: 28px; }
.shelf-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.shelf-head h2 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.shelf-head h2 small { font-size: 17px; font-weight: 600; color: var(--muted); margin-left: 4px; }
.see-all { flex: none; display: inline-flex; align-items: center; gap: 8px; color: var(--accent); font-weight: 600; font-size: 16px; }
.see-all .chev { color: inherit; width: 8px; height: 13px; }
.shelf-track {
  display: grid; grid-auto-flow: column; grid-template-rows: repeat(var(--rows, 3), auto);
  grid-auto-columns: 88%; column-gap: 20px; row-gap: 4px;
  overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none;
  margin: 0 -16px; padding: 0 16px 4px; scroll-padding: 16px;
}
.shelf-track::-webkit-scrollbar { display: none; }
.shelf-track > * { scroll-snap-align: start; }
@media (min-width: 640px) { .shelf-track { grid-auto-columns: calc(50% - 10px); } }
@media (min-width: 1000px) { .shelf-track { grid-auto-columns: calc(33.333% - 14px); } }
.stat .v a { color: var(--accent); }

/* ---------- Today (Home tab) ---------- */
.today-head { margin: 18px 0 14px; }
.today-head h1, .page-title { margin: 0; font-size: 34px; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; }
.page-title { margin-top: 18px; }

.hero-card {
  position: relative; display: block; overflow: hidden; isolation: isolate;
  height: min(480px, 118vw); border-radius: 26px; color: #fff;
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  box-shadow: 0 12px 32px rgba(0, 0, 0, .18);
  transition: transform .2s;
}
.hero-card:active { transform: scale(.985); }
@media (min-width: 640px) { .hero-card { height: 420px; } }
.hero-img {
  position: absolute; inset: 0; z-index: -2; width: 100%; height: 100%;
  object-fit: cover; opacity: 0; transition: opacity .4s;
}
.hero-card.has-img .hero-img { opacity: 1; }
.hero-card::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(to bottom, rgba(0, 0, 0, .78), rgba(0, 0, 0, .45) 22%, transparent 42%, transparent 62%, rgba(0, 0, 0, .35));
}
.hero-top {
  padding: 20px 20px 34px;
  /* Soft blur behind the title so busy screenshots stay readable; fades out downward. */
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  -webkit-mask-image: linear-gradient(#000 62%, transparent); mask-image: linear-gradient(#000 62%, transparent);
}
.hero-tag { font-size: 13px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; opacity: .85; }
.hero-top h2 {
  margin: 4px 0 0; font-size: 30px; font-weight: 800; line-height: 1.1; letter-spacing: -.02em;
  text-shadow: 0 2px 12px rgba(0, 0, 0, .35); overflow-wrap: anywhere;
}
.hero-foot {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; gap: 12px; padding: 14px 16px;
  background: rgba(0, 0, 0, .32);
  backdrop-filter: blur(22px) saturate(160%); -webkit-backdrop-filter: blur(22px) saturate(160%);
}
.hero-foot .card-name { font-size: 16px; }
.hero-foot .card-sub { color: rgba(255, 255, 255, .75); }
.hero-foot .get { background: rgba(255, 255, 255, .24); color: #fff; }

.cat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 640px) { .cat-grid { grid-template-columns: repeat(4, 1fr); } }
.cat-tile {
  display: flex; align-items: center; gap: 10px; min-width: 0; padding: 12px;
  border-radius: 16px; background: var(--surface); border: 1px solid var(--border);
  transition: border-color .15s, transform .15s;
}
.cat-tile:hover { border-color: var(--accent); }
.cat-tile:active { transform: scale(.97); }
.cat-ico { flex: none; width: 36px; height: 36px; border-radius: 10px; font-size: 20px; display: grid; place-items: center; background: var(--surface-2); }
.cat-name { flex: 1; min-width: 0; font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat-tile .n { flex: none; color: var(--muted); font-size: 13px; font-weight: 500; }
.browse-all { margin-top: 28px; }

/* ---------- Search: category cards ---------- */
#browse { margin-top: 24px; }
.cat-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 640px) { .cat-cards { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1000px) { .cat-cards { grid-template-columns: repeat(4, 1fr); } }
.cat-card {
  position: relative; overflow: hidden; height: 96px; padding: 12px 14px;
  display: flex; flex-direction: column; justify-content: flex-end; align-items: flex-start;
  border: 0; border-radius: 18px; cursor: pointer; text-align: left; color: #fff;
  background: linear-gradient(135deg, var(--c1), var(--c2));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18);
  transition: transform .15s;
  -webkit-tap-highlight-color: transparent;
}
.cat-card:active { transform: scale(.96); }
.cc-emoji {
  position: absolute; top: -4px; right: -6px; font-size: 52px; line-height: 1;
  transform: rotate(14deg); filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .3));
}
.cc-name { position: relative; font-weight: 800; font-size: 16px; line-height: 1.2; text-shadow: 0 1px 6px rgba(0, 0, 0, .25); }
.cc-n { position: relative; font-size: 12px; font-weight: 600; opacity: .85; }

.section-title .lt { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.clear-cat {
  flex: none; width: 26px; height: 26px; border: 0; border-radius: 999px; cursor: pointer;
  background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 700;
  display: inline-grid; place-items: center;
}
.clear-cat:hover { color: var(--text); }

/* ---------- Bottom tab bar (floating "liquid glass" capsule) ---------- */
:root { --glass: rgba(255, 255, 255, .62); --glass-edge: rgba(255, 255, 255, .7); --glass-pill: rgba(0, 0, 0, .07); --tab-ink: #1c1c1e; }
@media (prefers-color-scheme: dark) {
  :root { --glass: rgba(60, 60, 67, .5); --glass-edge: rgba(255, 255, 255, .16); --glass-pill: rgba(255, 255, 255, .13); --tab-ink: #f5f5f7; }
}
body:has(.tabbar) { padding-top: env(safe-area-inset-top); padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
.tabbar {
  position: fixed; z-index: 20; left: 50%; transform: translateX(-50%);
  bottom: calc(10px + env(safe-area-inset-bottom));
  width: calc(100% - 24px); max-width: 460px;
  display: flex; gap: 2px; padding: 5px;
  border-radius: 999px;
  background: var(--glass);
  backdrop-filter: blur(24px) saturate(190%);
  -webkit-backdrop-filter: blur(24px) saturate(190%);
  border: 1px solid var(--glass-edge);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .22), inset 0 1px 0 var(--glass-edge);
}
.tabbar a {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 7px 0 6px; border-radius: 999px;
  color: var(--tab-ink); font-size: 12px; font-weight: 600; letter-spacing: -.01em;
  transition: background .2s, color .2s;
  -webkit-tap-highlight-color: transparent;
}
.tabbar a[aria-current="page"] { color: var(--accent); background: var(--glass-pill); }
.tabbar svg { display: block; transition: transform .12s; }
.tabbar a:active svg { transform: scale(.88); }
