:root {
  --bg-color: #f8fafc;
  --surface-color: #ffffff;
  --border-color: #e2e8f0;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --primary-color: #3b82f6;
  --primary-hover: #2563eb;
  --success-color: #10b981;
  --danger-color: #ef4444;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --transition: all 0.2s ease-in-out;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  min-height: 100vh;
  width: 100%;
  overflow-x: hidden;
  background-color: var(--bg-color);
  background-image: 
    radial-gradient(at 0% 0%, hsla(217,100%,70%,0.15) 0px, transparent 50%),
    radial-gradient(at 100% 0%, hsla(189,100%,56%,0.15) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-primary);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

a {
  color: inherit;
  text-decoration: none;
  transition: var(--transition);
}

/* App Layout */
.app-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 12px 0 0;
}

.site-shell {
  width: calc(100% - 32px);
  max-width: 1200px;
  margin: 0 auto 16px;
  border: 1px solid #dbe6f1;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 0 20px 45px rgba(15, 35, 68, 0.12);
  backdrop-filter: blur(6px);
  overflow: hidden;
}

/* Navbar */
.navbar {
  position: sticky;
  top: 0;
  left: auto;
  transform: none;
  width: 100%;
  max-width: none;
  height: 48px;
  background: rgba(255, 255, 255, 0.95);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  box-shadow: none;
  border-bottom: 1px solid var(--border-color);
  z-index: 120;
}

.nav-btn {
  background: transparent;
  border: none;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  cursor: pointer;
  transition: var(--transition);
}

.nav-btn:hover {
  color: var(--primary-color);
}

.nav-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  flex: 1;
  text-align: center;
}

/* Category Bar */
.category-bar {
  position: sticky;
  top: 48px;
  left: auto;
  transform: none;
  width: 100%;
  max-width: none;
  height: 48px;
  background: rgba(248, 250, 252, 0.96);
  display: flex;
  align-items: center;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  padding: 0 8px;
  -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
  scrollbar-width: none; /* Firefox */
  z-index: 110;
  border-bottom: 1px solid var(--border-color);
}

.category-bar::-webkit-scrollbar {
  display: none; /* Chrome/Safari */
}

.cat-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  height: 100%;
  font-size: clamp(0.9rem, 2.5vw, 1rem); /* Responsive font size */
  font-weight: 600;
  color: var(--text-secondary);
  position: relative;
  transition: var(--transition);
  flex-shrink: 0;
}

.cat-link:hover {
  color: var(--text-primary);
}

.cat-link.active {
  color: var(--primary-color);
}

.cat-link.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 3px;
  background: var(--primary-color);
  border-radius: 3px 3px 0 0;
}

.main-content {
  position: relative;
  z-index: 80;
  flex: 1;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 16px;
}

.main-content.with-promo-bar {
  padding-bottom: 94px;
}

/* Remove old page and hero styles */

/* Main Panel */
.panel {
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  margin-bottom: 24px;
}

.panel h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.tip {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 16px;
}

.tip.error {
  color: var(--danger-color);
  background: #fef2f2;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid #fee2e2;
}

/* Tabs */
.home-tabs {
  display: inline-flex;
  background: var(--bg-color);
  padding: 4px;
  border-radius: 99px;
  margin-bottom: 24px;
  border: 1px solid var(--border-color);
}

.tab-btn {
  border: none;
  background: transparent;
  padding: 8px 20px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-radius: 99px;
  cursor: pointer;
  transition: var(--transition);
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  background: var(--surface-color);
  color: var(--primary-color);
  box-shadow: var(--shadow-sm);
}

/* List & Items */
.list-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.list-item {
  display: flex;
  align-items: center;
  padding: 12px;
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: var(--transition);
}

.list-item:hover {
  border-color: #bfdbfe;
  background: #f8fafc;
}

.list-icon {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  object-fit: cover;
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  flex-shrink: 0;
}

.list-info {
  flex: 1;
  min-width: 0; /* Prevent text overflow issues */
  margin: 0 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.list-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pin-badge {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 18px;
  padding: 0 7px;
  border-radius: 999px;
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  font-size: 11px;
  font-weight: 700;
}

.list-meta {
  color: var(--text-secondary);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Detail Button (for list) */
.btn-detail {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary-color);
  background: rgba(59, 130, 246, 0.1);
  border-radius: 99px;
  border: 1px solid rgba(59, 130, 246, 0.2);
  transition: var(--transition);
  flex-shrink: 0;
}

.btn-detail:hover {
  background: rgba(59, 130, 246, 0.2);
  transform: translateY(-1px);
}

/* Generic Buttons (used in App Detail) */
.actions {
  display: flex;
  gap: 12px;
}

.btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
}

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

.btn.primary {
  background: var(--primary-color);
  color: white;
  box-shadow: 0 2px 4px rgba(59, 130, 246, 0.25);
}

.btn.primary:hover {
  background: var(--primary-hover);
}

.btn.light {
  background: var(--bg-color);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn.light:hover {
  background: #f1f5f9;
}

.btn-spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #ffffff;
  animation: spin 0.8s linear infinite;
  margin-right: 8px;
}

/* App Detail */
.detail-img {
  width: 100%;
  max-width: 400px;
  height: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  margin: 20px 0;
  box-shadow: var(--shadow-sm);
}

.desc-pre {
  white-space: pre-wrap;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-color);
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  margin: 20px 0;
  font-size: 0.95rem;
}

/* Loading State */
.loading-pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .5; }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.retry-modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1200;
}

.retry-modal {
  width: 100%;
  max-width: 420px;
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 16px;
}

.retry-modal h3 {
  font-size: 1rem;
  margin-bottom: 8px;
}

.retry-modal-msg {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 12px;
}

.prompt-input {
  width: 100%;
  height: 40px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 0 12px;
  font-size: 14px;
  margin-bottom: 10px;
}

.retry-actions {
  display: flex;
  gap: 10px;
}

.force-gate-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.force-gate-actions .btn {
  flex: 1 1 120px;
}

.promo-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 10px;
  bottom: calc(constant(safe-area-inset-bottom) + 10px);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 10px);
  width: calc(100% - 24px);
  max-width: 840px;
  min-height: 52px;
  padding: 10px 14px;
  border-radius: 14px;
  background: linear-gradient(120deg, #0f766e 0%, #0369a1 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 10px 24px rgba(2, 132, 199, 0.28);
  z-index: 1100;
}

.promo-bar-text {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
}

.promo-bar-action {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.28);
  font-size: 13px;
  font-weight: 700;
}

/* Responsive */
@media (max-width: 768px) {
  .app-layout {
    padding-top: 0;
  }

.site-shell {
    width: 100%;
    margin: 0;
    border-radius: 0;
    border-left: none;
    border-right: none;
    box-shadow: none;
    backdrop-filter: none;
  }

  .navbar {
    width: 100%;
    max-width: none;
    height: 44px;
  }

  .category-bar {
    top: 44px;
    width: 100%;
    max-width: none;
    height: 44px;
  }

  .main-content {
    padding: 12px;
  }

  .panel {
    padding: 16px;
    border-radius: var(--radius-md);
  }

  .home-tabs {
    width: 100%;
    display: flex;
  }

  .tab-btn {
    flex: 1;
    text-align: center;
  }

  .main-content.with-promo-bar {
    padding-bottom: 102px;
  }

  .promo-bar {
    min-height: 50px;
    padding: 9px 12px;
    width: calc(100% - 16px);
    bottom: 8px;
    bottom: calc(constant(safe-area-inset-bottom) + 8px);
    bottom: calc(env(safe-area-inset-bottom, 0px) + 8px);
  }

  .promo-bar-text {
    font-size: 13px;
  }

  .promo-bar-action {
    height: 30px;
    font-size: 12px;
    padding: 0 10px;
  }
}

@media (max-width: 420px) {
  .nav-title {
    font-size: 1rem;
  }

  .cat-link {
    padding: 0 12px;
  }

  .panel {
    padding: 14px;
  }

  .list-item {
    padding: 10px;
  }

  .list-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
  }

  .list-info {
    margin: 0 10px;
  }

  .list-name {
    font-size: 0.98rem;
  }

  .list-meta {
    font-size: 0.78rem;
  }

  .btn-detail {
    padding: 6px 10px;
    font-size: 0.78rem;
  }

  .actions {
    flex-direction: column;
  }

  .promo-bar-text {
    max-width: calc(100% - 90px);
  }
}
