:root {
  color-scheme: dark;
  --bg: #0f1115;
  --bg-elev: #161922;
  --bg-card: #1c2030;
  --bg-card-hover: #232838;
  --border: #262b3a;
  --text: #e7e9ee;
  --text-dim: #8a93a6;
  --accent: #4f8cff;
  --accent-dim: #2a3b66;
  --gold: #ffc23c;
  --bottom-nav-h: 62px;
}

* { 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 Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

img { -webkit-user-drag: none; user-select: none; }

button { font-family: inherit; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: rgba(22, 25, 34, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.brand .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #7a5cff);
  box-shadow: 0 0 12px rgba(79, 140, 255, 0.6);
}
.brand .title { font-weight: 700; font-size: 16px; letter-spacing: 0.2px; }

.searchwrap { flex: 1; min-width: 0; }
#search {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  background: #11141c;
  color: var(--text);
  border-radius: 10px;
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
}
#search:focus { border-color: var(--accent); }

.iconbtn {
  flex-shrink: 0;
  width: 38px; height: 38px;
  border: 1px solid var(--border);
  background: #11141c;
  color: var(--text);
  border-radius: 10px;
  font-size: 18px;
  cursor: pointer;
}
.iconbtn:active { background: var(--bg-card-hover); }

/* ---------- Pull to refresh ---------- */
.ptr {
  position: relative;
  height: 0;
  overflow: hidden;
  transition: height .15s;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
}
.ptr.armed { color: var(--accent); }
.ptr-spinner {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
  opacity: 0;
  transition: opacity .15s;
}
.ptr.visible .ptr-spinner { opacity: 1; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Content area ---------- */
.content {
  padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px) + 12px);
  min-height: 60vh;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 16px 14px 8px;
}
.section-head .title { font-size: 15px; font-weight: 700; letter-spacing: 0.3px; }
.section-head .seeall {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 6px;
}

/* ---------- Horizontal row strip ---------- */
.row {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scroll-padding: 14px;
  padding: 0 14px 6px;
  scrollbar-width: none;
}
.row::-webkit-scrollbar { display: none; }

.row-card {
  flex: 0 0 auto;
  width: 124px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  scroll-snap-align: start;
  position: relative;
  transition: background .15s, transform .08s;
}
.row-card:hover { background: var(--bg-card-hover); }
.row-card:active { transform: scale(0.97); }

/* ---------- Grid view ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
  padding: 6px 12px 12px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 120px;
  cursor: pointer;
  position: relative;
  transition: background .15s, transform .08s;
}
.card:hover { background: var(--bg-card-hover); }
.card:active { transform: scale(0.97); }

/* Shared card internals */
.logo {
  width: 64px; height: 64px;
  object-fit: contain;
  border-radius: 8px;
  background: #0b0d13;
  padding: 6px;
}
.row-card .logo { width: 72px; height: 72px; }
.logo.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 22px;
  color: var(--accent);
  background: linear-gradient(135deg, #1a2138, #2a1f3b);
}
.name {
  font-size: 12.5px;
  font-weight: 600;
  text-align: center;
  line-height: 1.2;
  color: var(--text);
  word-break: break-word;
  max-height: 2.4em;
  overflow: hidden;
}

.fav-btn {
  position: absolute;
  top: 6px; right: 6px;
  width: 28px; height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  opacity: 0.85;
  transition: transform .12s, background .15s, color .15s;
}
.fav-btn:active { transform: scale(0.85); }
.fav-btn.on { color: var(--gold); background: rgba(0, 0, 0, 0.7); opacity: 1; }

/* ---------- Empty / loading ---------- */
.empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-dim);
  font-size: 14px;
}

.skeleton-row { padding-top: 14px; }
.skel-head {
  height: 14px;
  width: 120px;
  margin: 0 14px 10px;
  border-radius: 4px;
  background: linear-gradient(90deg, #1a1e2a 25%, #232838 50%, #1a1e2a 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}
.skel-card {
  flex: 0 0 auto;
  width: 124px;
  height: 130px;
  border-radius: 12px;
  background: linear-gradient(90deg, #1a1e2a 25%, #232838 50%, #1a1e2a 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ---------- Bottom navigation ---------- */
.bottom-nav {
  position: fixed;
  left: 0; right: 0;
  bottom: 0;
  height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(22, 25, 34, 0.96);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 30;
}
.nav-btn {
  flex: 1;
  background: none;
  border: 0;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 4px;
  transition: color .15s;
}
.nav-btn .icon { font-size: 20px; line-height: 1; }
.nav-btn.active { color: var(--accent); }
.nav-btn:active { background: rgba(255, 255, 255, 0.04); }

/* ---------- Sheet (More categories) ---------- */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.sheet[hidden] { display: none; }
.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  animation: fadein .15s ease;
}
.sheet-body {
  position: relative;
  background: var(--bg-elev);
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  padding: 8px 0 calc(env(safe-area-inset-bottom, 0px) + 12px);
  max-height: 70vh;
  overflow-y: auto;
  animation: slideup .2s ease;
}
.sheet-handle {
  width: 40px; height: 4px;
  border-radius: 2px;
  background: #3a3f50;
  margin: 6px auto 12px;
}
.sheet-title { padding: 0 18px 8px; font-size: 13px; color: var(--text-dim); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.sheet-list { list-style: none; margin: 0; padding: 0; }
.sheet-item {
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.sheet-item:last-child { border-bottom: 0; }
.sheet-item:active { background: var(--bg-card-hover); }
.sheet-item .icon { font-size: 20px; width: 24px; text-align: center; }
.sheet-item .count { margin-left: auto; color: var(--text-dim); font-weight: 500; font-size: 13px; }

@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideup { from { transform: translateY(40px); } to { transform: translateY(0); } }
