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

:root {
  --green: #01875f;
  --green-dark: #016b4d;
  --bg: #f8f9fa;
  --surface: #ffffff;
  --border: #e0e0e0;
  --text: #202124;
  --text-muted: #5f6368;
  --shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.16);
  --radius: 12px;
}

body {
  font-family: 'Roboto', 'Google Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Header ── */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--green);
  text-decoration: none;
  flex-shrink: 0;
}

.logo-icon { width: 28px; height: 28px; }

.logo-text {
  font-family: 'Google Sans', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.search-bar {
  flex: 1;
  max-width: 600px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: #f1f3f4;
  border-radius: 24px;
  padding: 0 16px;
  height: 42px;
  transition: background 0.2s, box-shadow 0.2s;
}

.search-bar:focus-within {
  background: var(--surface);
  box-shadow: 0 0 0 2px var(--green);
}

.search-bar svg { width: 20px; height: 20px; color: var(--text-muted); flex-shrink: 0; }

.search-bar input {
  border: none;
  background: transparent;
  font-size: 15px;
  outline: none;
  width: 100%;
  color: var(--text);
}

/* ── Categories ── */
.categories-nav {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px 24px 0;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.categories-nav::-webkit-scrollbar { display: none; }

.cat-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: 20px;
  padding: 8px 18px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.cat-btn:hover { border-color: var(--green); color: var(--green); }

.cat-btn.active {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

/* ── Main grid ── */
.main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

.apps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 20px;
}

/* ── App Card ── */
.app-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px 16px 16px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  border: 1px solid transparent;
}

.app-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--border);
}

.app-card-icon {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  object-fit: cover;
  background: #f1f3f4;
}

.app-card-icon-placeholder {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.app-card-name {
  font-family: 'Google Sans', sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.app-card-category {
  font-size: 12px;
  color: var(--text-muted);
}

.app-card-version {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: auto;
  background: #f1f3f4;
  padding: 3px 10px;
  border-radius: 20px;
}

/* ── States ── */
.loading-state, .empty-state {
  grid-column: 1/-1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 80px 24px;
  color: var(--text-muted);
}

.loading-state svg, .empty-state svg {
  width: 64px;
  height: 64px;
  opacity: 0.3;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.hidden { display: none !important; }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border-radius: 20px;
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 32px;
  position: relative;
  animation: slideUp 0.2s ease;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: #f1f3f4;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: background 0.15s;
}

.modal-close:hover { background: var(--border); }
.modal-close svg { width: 18px; height: 18px; }

.modal-header {
  display: flex;
  gap: 20px;
  margin-bottom: 24px;
}

.modal-icon {
  width: 100px;
  height: 100px;
  border-radius: 20px;
  object-fit: cover;
  background: #f1f3f4;
  flex-shrink: 0;
}

.modal-icon-placeholder {
  width: 100px;
  height: 100px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.modal-header-info { display: flex; flex-direction: column; gap: 6px; flex: 1; }

.modal-title {
  font-family: 'Google Sans', sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.modal-category { font-size: 14px; color: var(--green); font-weight: 500; }

.modal-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.dot { color: var(--border); }

.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 24px;
  padding: 10px 24px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  margin-top: 8px;
  transition: background 0.15s, transform 0.1s;
  width: fit-content;
}

.btn-download:hover { background: var(--green-dark); transform: scale(1.02); }
.btn-download svg { width: 20px; height: 20px; }

/* Screenshots */
.modal-screenshots {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  margin-bottom: 24px;
  scrollbar-width: none;
  padding-bottom: 4px;
}

.modal-screenshots::-webkit-scrollbar { display: none; }

.modal-screenshots img {
  height: 180px;
  width: auto;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--border);
}

.modal-section { margin-bottom: 24px; }

.modal-section h3 {
  font-family: 'Google Sans', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
}

.modal-section p {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.7;
}

.modal-section pre {
  font-family: 'Roboto', sans-serif;
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.7;
  white-space: pre-wrap;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.info-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px;
  background: #f8f9fa;
  border-radius: 8px;
}

.info-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-weight: 500;
}

.info-item span:last-child { font-size: 13px; color: var(--text); font-weight: 500; }

/* ── Responsive ── */
@media (max-width: 600px) {
  .header-inner { padding: 0 16px; gap: 12px; }
  .logo-text { display: none; }
  .main { padding: 16px; }
  .apps-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
  .modal { padding: 24px 16px; border-radius: 16px 16px 0 0; max-height: 92vh; }
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal-header { flex-direction: column; align-items: center; text-align: center; }
  .modal-meta { justify-content: center; }
  .btn-download { width: 100%; justify-content: center; }
}
