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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--tg-theme-bg-color, #ffffff);
  color: var(--tg-theme-text-color, #000000);
  min-height: 100vh;
  overflow-x: hidden;
}

header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--tg-theme-bg-color, #ffffff);
  border-bottom: 1px solid var(--tg-theme-hint-color, #cccccc);
  padding-bottom: 0;
}

.app-title {
  font-size: 20px;
  font-weight: 700;
  padding: 14px 16px 10px;
  color: var(--tg-theme-text-color, #000000);
}

.tabs {
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 0 16px;
  gap: 4px;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  flex-shrink: 0;
  padding: 8px 16px;
  border: none;
  border-radius: 20px 20px 0 0;
  background: transparent;
  color: var(--tg-theme-hint-color, #999999);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border-bottom: 2px solid transparent;
}

.tab.active {
  color: var(--tg-theme-button-color, #2481cc);
  border-bottom: 2px solid var(--tg-theme-button-color, #2481cc);
  background: transparent;
}

main {
  padding: 12px 8px;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.card {
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  background: var(--tg-theme-secondary-bg-color, #f0f0f0);
  aspect-ratio: 1;
  transition: transform 0.15s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.card:active {
  transform: scale(0.97);
}

.card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card .label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 20px 10px 10px;
  background: linear-gradient(transparent, rgba(0,0,0,0.55));
  color: #ffffff;
  font-size: 13px;
  font-weight: 500;
}

.skeleton {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #e0e0e0 25%, #f0f0f0 50%, #e0e0e0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  align-items: center;
  justify-content: center;
}

.modal.open {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
}

.modal-content {
  position: relative;
  z-index: 1;
  max-width: 92vw;
  max-height: 85vh;
  border-radius: 16px;
  overflow: hidden;
}

.modal-img {
  display: block;
  max-width: 92vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: 16px;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.5);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
